Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
2d49c262
Unverified
Commit
2d49c262
authored
Jan 13, 2022
by
Roman Sedaikin
Committed by
GitHub
Jan 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further commonization of skiko events. (#430)
parent
2cc4b1c9
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
228 additions
and
104 deletions
+228
-104
Clocks.kt
...rc/commonMain/kotlin/org/jetbrains/skiko/sample/Clocks.kt
+10
-3
test.run.xml
skiko/.run/test.run.xml
+2
-4
Convertors.jvm.kt
.../src/awtMain/kotlin/org/jetbrains/skiko/Convertors.jvm.kt
+40
-34
SkiaLayer.awt.kt
...o/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
+8
-3
SkikoKey.awt.kt
skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkikoKey.awt.kt
+1
-1
Events.kt
skiko/src/commonMain/kotlin/org/jetbrains/skiko/Events.kt
+23
-3
SkikoView.kt
skiko/src/commonMain/kotlin/org/jetbrains/skiko/SkikoView.kt
+5
-0
Convertors.ios.kt
.../src/iosMain/kotlin/org/jetbrains/skiko/Convertors.ios.kt
+8
-2
SkiaLayer.ios.kt
...o/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
+2
-1
SkikoViewController.kt
...iosMain/kotlin/org/jetbrains/skiko/SkikoViewController.kt
+53
-12
Convertors.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skiko/Convertors.js.kt
+24
-18
SkiaLayer.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skiko/SkiaLayer.js.kt
+1
-0
SkiaLayer.linux.kt
...c/linuxMain/kotlin/org/jetbrains/skiko/SkiaLayer.linux.kt
+1
-0
Convertors.macos.kt
.../macosMain/kotlin/org/jetbrains/skiko/Convertors.macos.kt
+44
-20
SkiaLayer.macos.kt
...c/macosMain/kotlin/org/jetbrains/skiko/SkiaLayer.macos.kt
+6
-3
No files found.
samples/SkiaMultiplatformSample/src/commonMain/kotlin/org/jetbrains/skiko/sample/Clocks.kt
View file @
2d49c262
...
@@ -129,11 +129,11 @@ class Clocks(private val layer: SkiaLayer): SkikoView {
...
@@ -129,11 +129,11 @@ class Clocks(private val layer: SkiaLayer): SkikoView {
SkikoPointerEventKind
.
SCROLL
->
{
SkikoPointerEventKind
.
SCROLL
->
{
when
(
event
.
modifiers
)
{
when
(
event
.
modifiers
)
{
SkikoInputModifiers
.
CONTROL
->
{
SkikoInputModifiers
.
CONTROL
->
{
rotate
+=
if
(
event
.
y
<
0
)
-
5.0
else
5.0
rotate
+=
if
(
event
.
deltaY
<
0
)
-
5.0
else
5.0
}
}
else
->
{
else
->
{
if
(
event
.
y
!=
0.0
)
{
if
(
event
.
y
!=
0.0
)
{
scale
*=
if
(
event
.
y
<
0
)
0.9
else
1.1
scale
*=
if
(
event
.
deltaY
<
0
)
0.9
else
1.1
}
}
}
}
}
}
...
@@ -194,9 +194,16 @@ class Clocks(private val layer: SkiaLayer): SkikoView {
...
@@ -194,9 +194,16 @@ class Clocks(private val layer: SkiaLayer): SkikoView {
}
}
}
}
override
fun
onTouchEvent
(
events
:
Array
<
SkikoTouchEvent
>)
{
val
event
=
events
.
first
()
if
(
event
.
kind
==
SkikoTouchEventKind
.
STARTED
)
{
xpos
=
event
.
x
-
xOffset
ypos
=
event
.
y
-
yOffset
}
}
override
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
{
override
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
{
when
(
event
.
kind
)
{
when
(
event
.
kind
)
{
SkikoGestureEventKind
.
PRESS
,
SkikoGestureEventKind
.
TAP
->
{
SkikoGestureEventKind
.
TAP
->
{
xpos
=
event
.
x
-
xOffset
xpos
=
event
.
x
-
xOffset
ypos
=
event
.
y
-
yOffset
ypos
=
event
.
y
-
yOffset
...
...
skiko/.run/test.run.xml
View file @
2d49c262
...
@@ -13,9 +13,7 @@
...
@@ -13,9 +13,7 @@
</option>
</option>
<option
name=
"vmOptions"
/>
<option
name=
"vmOptions"
/>
</ExternalSystemSettings>
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>
true
</ExternalSystemDebugServerProcess>
<GradleScriptDebugEnabled>
true
</GradleScriptDebugEnabled>
<ExternalSystemReattachDebugProcess>
true
</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>
false
</DebugAllEnabled>
<method
v=
"2"
/>
<method
v=
"2"
/>
</configuration>
</configuration>
</component>
</component>
\ No newline at end of file
skiko/src/awtMain/kotlin/org/jetbrains/skiko/Convertors.jvm.kt
View file @
2d49c262
...
@@ -77,11 +77,11 @@ fun BufferedImage.toImage(): Image {
...
@@ -77,11 +77,11 @@ fun BufferedImage.toImage(): Image {
fun
toSkikoEvent
(
event
:
MouseEvent
):
SkikoPointerEvent
{
fun
toSkikoEvent
(
event
:
MouseEvent
):
SkikoPointerEvent
{
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
event
.
x
.
toDouble
(),
x
=
event
.
x
.
toDouble
(),
event
.
y
.
toDouble
(),
y
=
event
.
y
.
toDouble
(),
toSkikoMouseButtons
(
event
.
modifiersEx
),
buttons
=
toSkikoMouseButtons
(
event
.
modifiersEx
),
toSkikoModifiers
(
event
.
modifiersEx
),
modifiers
=
toSkikoModifiers
(
event
.
modifiersEx
),
when
(
event
.
id
)
{
kind
=
when
(
event
.
id
)
{
MouseEvent
.
MOUSE_PRESSED
->
SkikoPointerEventKind
.
DOWN
MouseEvent
.
MOUSE_PRESSED
->
SkikoPointerEventKind
.
DOWN
MouseEvent
.
MOUSE_RELEASED
->
SkikoPointerEventKind
.
UP
MouseEvent
.
MOUSE_RELEASED
->
SkikoPointerEventKind
.
UP
MouseEvent
.
MOUSE_DRAGGED
->
SkikoPointerEventKind
.
DRAG
MouseEvent
.
MOUSE_DRAGGED
->
SkikoPointerEventKind
.
DRAG
...
@@ -90,7 +90,8 @@ fun toSkikoEvent(event: MouseEvent): SkikoPointerEvent {
...
@@ -90,7 +90,8 @@ fun toSkikoEvent(event: MouseEvent): SkikoPointerEvent {
MouseEvent
.
MOUSE_EXITED
->
SkikoPointerEventKind
.
EXIT
MouseEvent
.
MOUSE_EXITED
->
SkikoPointerEventKind
.
EXIT
else
->
SkikoPointerEventKind
.
UNKNOWN
else
->
SkikoPointerEventKind
.
UNKNOWN
},
},
event
timestamp
=
event
.
`when`
,
platform
=
event
)
)
}
}
...
@@ -98,60 +99,65 @@ fun toSkikoEvent(event: MouseWheelEvent): SkikoPointerEvent {
...
@@ -98,60 +99,65 @@ fun toSkikoEvent(event: MouseWheelEvent): SkikoPointerEvent {
val
scrollAmount
=
event
.
getPreciseWheelRotation
()
val
scrollAmount
=
event
.
getPreciseWheelRotation
()
val
modifiers
=
toSkikoModifiers
(
event
.
modifiersEx
)
val
modifiers
=
toSkikoModifiers
(
event
.
modifiersEx
)
val
isShiftPressed
=
modifiers
.
has
(
SkikoInputModifiers
.
SHIFT
)
val
isShiftPressed
=
modifiers
.
has
(
SkikoInputModifiers
.
SHIFT
)
val
x
=
if
(
isShiftPressed
)
scrollAmount
else
0.0
val
deltaX
=
if
(
isShiftPressed
)
scrollAmount
else
0.0
val
y
=
if
(
isShiftPressed
)
0.0
else
scrollAmount
val
deltaY
=
if
(
isShiftPressed
)
0.0
else
scrollAmount
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
x
,
x
=
event
.
x
.
toDouble
(),
y
,
y
=
event
.
y
.
toDouble
(),
toSkikoMouseButtons
(
event
.
modifiersEx
),
deltaX
=
deltaX
,
modifiers
,
deltaY
=
deltaY
,
when
(
event
.
id
)
{
buttons
=
toSkikoMouseButtons
(
event
.
modifiersEx
),
modifiers
=
modifiers
,
kind
=
when
(
event
.
id
)
{
MouseEvent
.
MOUSE_WHEEL
->
SkikoPointerEventKind
.
SCROLL
MouseEvent
.
MOUSE_WHEEL
->
SkikoPointerEventKind
.
SCROLL
else
->
SkikoPointerEventKind
.
UNKNOWN
else
->
SkikoPointerEventKind
.
UNKNOWN
},
},
event
timestamp
=
event
.
`when`
,
platform
=
event
)
)
}
}
fun
toSkikoEvent
(
event
:
KeyEvent
):
SkikoKeyboardEvent
{
fun
toSkikoEvent
(
event
:
KeyEvent
):
SkikoKeyboardEvent
{
var
key
=
event
.
keyCode
val
side
=
event
.
getKeyLocation
()
if
(
side
==
KEY_LOCATION_RIGHT
)
{
if
(
key
==
SkikoKey
.
KEY_LEFT_CONTROL
.
value
||
key
==
SkikoKey
.
KEY_LEFT_SHIFT
.
value
||
key
==
SkikoKey
.
KEY_LEFT_META
.
value
)
key
=
key
.
or
(
0
x80000000
.
toInt
())
}
if
(
side
==
KEY_LOCATION_NUMPAD
)
{
if
(
key
==
SkikoKey
.
KEY_ENTER
.
value
)
{
key
=
key
.
or
(
0
x80000000
.
toInt
())
}
}
return
SkikoKeyboardEvent
(
return
SkikoKeyboardEvent
(
SkikoKey
.
valueOf
(
key
),
SkikoKey
.
valueOf
(
toSkikoKey
(
event
)
),
toSkikoModifiers
(
event
.
modifiersEx
),
toSkikoModifiers
(
event
.
modifiersEx
),
when
(
event
.
id
)
{
when
(
event
.
id
)
{
KeyEvent
.
KEY_PRESSED
->
SkikoKeyboardEventKind
.
DOWN
KeyEvent
.
KEY_PRESSED
->
SkikoKeyboardEventKind
.
DOWN
KeyEvent
.
KEY_RELEASED
->
SkikoKeyboardEventKind
.
UP
KeyEvent
.
KEY_RELEASED
->
SkikoKeyboardEventKind
.
UP
else
->
SkikoKeyboardEventKind
.
UNKNOWN
else
->
SkikoKeyboardEventKind
.
UNKNOWN
},
},
event
.
`when`
,
event
event
)
)
}
}
fun
toSkikoTypeEvent
(
event
:
KeyEvent
):
SkikoInputEvent
{
fun
toSkikoTypeEvent
(
typeEvent
:
KeyEvent
,
keyEvent
:
KeyEvent
?):
SkikoInputEvent
{
var
key
:
Int
=
-
1
var
modifiers
=
SkikoInputModifiers
.
EMPTY
if
(
keyEvent
!=
null
)
{
key
=
toSkikoKey
(
keyEvent
)
modifiers
=
toSkikoModifiers
(
keyEvent
.
modifiersEx
)
}
return
SkikoInputEvent
(
return
SkikoInputEvent
(
event
.
keyChar
.
toString
(),
typeEvent
.
keyChar
.
toString
(),
SkikoKey
.
valueOf
(
key
),
modifiers
,
SkikoKeyboardEventKind
.
TYPE
,
SkikoKeyboardEventKind
.
TYPE
,
e
vent
typeE
vent
)
)
}
}
fun
toSkikoEvent
(
event
:
InputMethodEvent
):
SkikoInputEvent
{
fun
toSkikoTypeEvent
(
event
:
InputMethodEvent
,
keyEvent
:
KeyEvent
?):
SkikoInputEvent
{
var
key
:
Int
=
-
1
var
modifiers
=
SkikoInputModifiers
.
EMPTY
if
(
keyEvent
!=
null
)
{
key
=
toSkikoKey
(
keyEvent
)
modifiers
=
toSkikoModifiers
(
keyEvent
.
modifiersEx
)
}
return
SkikoInputEvent
(
return
SkikoInputEvent
(
""
,
""
,
SkikoKey
.
valueOf
(
key
),
modifiers
,
SkikoKeyboardEventKind
.
TYPE
,
SkikoKeyboardEventKind
.
TYPE
,
event
event
)
)
...
...
skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
View file @
2d49c262
...
@@ -157,6 +157,8 @@ actual open class SkiaLayer internal constructor(
...
@@ -157,6 +157,8 @@ actual open class SkiaLayer internal constructor(
jComponent
.
add
(
this
)
jComponent
.
add
(
this
)
}
}
private
var
keyEvent
:
KeyEvent
?
=
null
fun
addView
(
view
:
SkikoView
)
{
fun
addView
(
view
:
SkikoView
)
{
skikoView
=
view
skikoView
=
view
addMouseListener
(
object
:
MouseAdapter
()
{
addMouseListener
(
object
:
MouseAdapter
()
{
...
@@ -191,22 +193,24 @@ actual open class SkiaLayer internal constructor(
...
@@ -191,22 +193,24 @@ actual open class SkiaLayer internal constructor(
addKeyListener
(
object
:
KeyAdapter
()
{
addKeyListener
(
object
:
KeyAdapter
()
{
override
fun
keyPressed
(
e
:
KeyEvent
)
{
override
fun
keyPressed
(
e
:
KeyEvent
)
{
keyEvent
=
e
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
e
))
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
e
))
}
}
override
fun
keyReleased
(
e
:
KeyEvent
)
{
override
fun
keyReleased
(
e
:
KeyEvent
)
{
keyEvent
=
e
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
e
))
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
e
))
}
}
override
fun
keyTyped
(
e
:
KeyEvent
)
{
override
fun
keyTyped
(
e
:
KeyEvent
)
{
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
e
))
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
e
,
keyEvent
))
}
}
})
})
addInputMethodListener
(
object
:
InputMethodListener
{
addInputMethodListener
(
object
:
InputMethodListener
{
override
fun
caretPositionChanged
(
e
:
InputMethodEvent
)
{
override
fun
caretPositionChanged
(
e
:
InputMethodEvent
)
{
skikoView
?.
onInputEvent
(
toSkiko
Event
(
e
))
skikoView
?.
onInputEvent
(
toSkiko
TypeEvent
(
e
,
keyEvent
))
}
}
override
fun
inputMethodTextChanged
(
e
:
InputMethodEvent
)
{
override
fun
inputMethodTextChanged
(
e
:
InputMethodEvent
)
{
skikoView
?.
onInputEvent
(
toSkiko
Event
(
e
))
skikoView
?.
onInputEvent
(
toSkiko
TypeEvent
(
e
,
keyEvent
))
}
}
})
})
}
}
...
@@ -546,6 +550,7 @@ internal fun defaultFPSCounter(
...
@@ -546,6 +550,7 @@ internal fun defaultFPSCounter(
}
}
// InputEvent is abstract, so we wrap to match modality.
// InputEvent is abstract, so we wrap to match modality.
actual
typealias
SkikoTouchPlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoPlatformInputEvent
=
Any
actual
typealias
SkikoPlatformInputEvent
=
Any
actual
typealias
SkikoPlatformKeyboardEvent
=
KeyEvent
actual
typealias
SkikoPlatformKeyboardEvent
=
KeyEvent
...
...
skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkikoKey.awt.kt
View file @
2d49c262
...
@@ -5,7 +5,7 @@ import java.awt.event.KeyEvent.*
...
@@ -5,7 +5,7 @@ import java.awt.event.KeyEvent.*
actual
enum
class
SkikoKey
(
val
value
:
Int
)
{
actual
enum
class
SkikoKey
(
val
value
:
Int
)
{
KEY_UNKNOWN
(-
1
),
KEY_UNKNOWN
(-
1
),
KEY_A
(
VK_A
),
KEY_A
(
VK_A
),
KEY_S
(
VK_
B
),
KEY_S
(
VK_
S
),
KEY_D
(
VK_D
),
KEY_D
(
VK_D
),
KEY_F
(
VK_F
),
KEY_F
(
VK_F
),
KEY_H
(
VK_H
),
KEY_H
(
VK_H
),
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skiko/Events.kt
View file @
2d49c262
...
@@ -199,7 +199,7 @@ expect enum class SkikoKey {
...
@@ -199,7 +199,7 @@ expect enum class SkikoKey {
}
}
enum
class
SkikoGestureEventKind
{
enum
class
SkikoGestureEventKind
{
PRESS
,
TAP
,
PAN
,
PINCH
,
ROTATION
,
LONGPRESS
,
SWIPE
,
UNKNOWN
TAP
,
PAN
,
PINCH
,
ROTATION
,
LONGPRESS
,
SWIPE
,
UNKNOWN
}
}
enum
class
SkikoGestureEventDirection
{
enum
class
SkikoGestureEventDirection
{
UP
,
DOWN
,
LEFT
,
RIGHT
,
UNKNOWN
UP
,
DOWN
,
LEFT
,
RIGHT
,
UNKNOWN
...
@@ -209,7 +209,8 @@ enum class SkikoGestureEventState {
...
@@ -209,7 +209,8 @@ enum class SkikoGestureEventState {
}
}
expect
class
SkikoGesturePlatformEvent
expect
class
SkikoGesturePlatformEvent
data class
SkikoGestureEvent
(
data class
SkikoGestureEvent
(
val
x
:
Double
,
val
y
:
Double
,
val
x
:
Double
,
val
y
:
Double
,
val
velocity
:
Double
=
0.0
,
val
velocity
:
Double
=
0.0
,
val
direction
:
SkikoGestureEventDirection
=
SkikoGestureEventDirection
.
UNKNOWN
,
val
direction
:
SkikoGestureEventDirection
=
SkikoGestureEventDirection
.
UNKNOWN
,
val
rotation
:
Double
=
0.0
,
val
rotation
:
Double
=
0.0
,
...
@@ -219,9 +220,23 @@ data class SkikoGestureEvent(
...
@@ -219,9 +220,23 @@ data class SkikoGestureEvent(
val
platform
:
SkikoGesturePlatformEvent
?
=
null
val
platform
:
SkikoGesturePlatformEvent
?
=
null
)
)
enum
class
SkikoTouchEventKind
{
STARTED
,
ENDED
,
MOVED
,
CANCELLED
,
UNKNOWN
}
expect
class
SkikoTouchPlatformEvent
data class
SkikoTouchEvent
(
val
x
:
Double
,
val
y
:
Double
,
val
kind
:
SkikoTouchEventKind
=
SkikoTouchEventKind
.
UNKNOWN
,
val
timestamp
:
Long
=
0
,
val
platform
:
SkikoTouchPlatformEvent
?
=
null
)
expect
class
SkikoPlatformInputEvent
expect
class
SkikoPlatformInputEvent
data class
SkikoInputEvent
(
data class
SkikoInputEvent
(
val
input
:
String
,
val
input
:
String
,
val
key
:
SkikoKey
,
val
modifiers
:
SkikoInputModifiers
=
SkikoInputModifiers
.
EMPTY
,
val
kind
:
SkikoKeyboardEventKind
,
val
kind
:
SkikoKeyboardEventKind
,
val
platform
:
SkikoPlatformInputEvent
?
val
platform
:
SkikoPlatformInputEvent
?
)
)
...
@@ -234,6 +249,7 @@ data class SkikoKeyboardEvent(
...
@@ -234,6 +249,7 @@ data class SkikoKeyboardEvent(
val
key
:
SkikoKey
,
val
key
:
SkikoKey
,
val
modifiers
:
SkikoInputModifiers
=
SkikoInputModifiers
.
EMPTY
,
val
modifiers
:
SkikoInputModifiers
=
SkikoInputModifiers
.
EMPTY
,
val
kind
:
SkikoKeyboardEventKind
,
val
kind
:
SkikoKeyboardEventKind
,
val
timestamp
:
Long
=
0
,
val
platform
:
SkikoPlatformKeyboardEvent
?
val
platform
:
SkikoPlatformKeyboardEvent
?
)
)
...
@@ -243,10 +259,14 @@ enum class SkikoPointerEventKind {
...
@@ -243,10 +259,14 @@ enum class SkikoPointerEventKind {
expect
class
SkikoPlatformPointerEvent
expect
class
SkikoPlatformPointerEvent
data class
SkikoPointerEvent
(
data class
SkikoPointerEvent
(
val
x
:
Double
,
val
y
:
Double
,
val
x
:
Double
,
val
y
:
Double
,
val
deltaX
:
Double
=
0.0
,
val
deltaY
:
Double
=
0.0
,
val
buttons
:
SkikoMouseButtons
=
SkikoMouseButtons
.
NONE
,
val
buttons
:
SkikoMouseButtons
=
SkikoMouseButtons
.
NONE
,
val
modifiers
:
SkikoInputModifiers
=
SkikoInputModifiers
.
EMPTY
,
val
modifiers
:
SkikoInputModifiers
=
SkikoInputModifiers
.
EMPTY
,
val
kind
:
SkikoPointerEventKind
,
val
kind
:
SkikoPointerEventKind
,
val
timestamp
:
Long
=
0
,
val
platform
:
SkikoPlatformPointerEvent
?
val
platform
:
SkikoPlatformPointerEvent
?
)
)
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skiko/SkikoView.kt
View file @
2d49c262
...
@@ -7,6 +7,7 @@ interface SkikoView {
...
@@ -7,6 +7,7 @@ interface SkikoView {
fun
onKeyboardEvent
(
event
:
SkikoKeyboardEvent
)
=
Unit
fun
onKeyboardEvent
(
event
:
SkikoKeyboardEvent
)
=
Unit
fun
onPointerEvent
(
event
:
SkikoPointerEvent
)
=
Unit
fun
onPointerEvent
(
event
:
SkikoPointerEvent
)
=
Unit
fun
onInputEvent
(
event
:
SkikoInputEvent
)
=
Unit
fun
onInputEvent
(
event
:
SkikoInputEvent
)
=
Unit
fun
onTouchEvent
(
events
:
Array
<
SkikoTouchEvent
>)
=
Unit
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
=
Unit
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
=
Unit
// Rendering
// Rendering
...
@@ -38,6 +39,10 @@ open class GenericSkikoView(
...
@@ -38,6 +39,10 @@ open class GenericSkikoView(
app
.
onPointerEvent
(
event
)
app
.
onPointerEvent
(
event
)
}
}
override
fun
onTouchEvent
(
events
:
Array
<
SkikoTouchEvent
>)
{
app
.
onTouchEvent
(
events
)
}
override
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
{
override
fun
onGestureEvent
(
event
:
SkikoGestureEvent
)
{
app
.
onGestureEvent
(
event
)
app
.
onGestureEvent
(
event
)
}
}
...
...
skiko/src/iosMain/kotlin/org/jetbrains/skiko/Convertors.ios.kt
View file @
2d49c262
...
@@ -22,11 +22,15 @@ fun toSkikoGestureState(state: UIGestureRecognizerState ) : SkikoGestureEventSta
...
@@ -22,11 +22,15 @@ fun toSkikoGestureState(state: UIGestureRecognizerState ) : SkikoGestureEventSta
}
}
}
}
fun
toSkikoTypeEvent
(
character
:
String
):
SkikoInputEvent
{
fun
toSkikoTypeEvent
(
character
:
String
,
event
:
UIPress
?):
SkikoInputEvent
{
val
key
=
if
(
event
!=
null
)
SkikoKey
.
valueOf
(
event
.
key
!!
.
keyCode
)
else
SkikoKey
.
KEY_UNKNOWN
val
modifiers
=
if
(
event
!=
null
)
toSkikoModifiers
(
event
)
else
SkikoInputModifiers
.
EMPTY
return
SkikoInputEvent
(
return
SkikoInputEvent
(
character
,
character
,
key
,
modifiers
,
SkikoKeyboardEventKind
.
TYPE
,
SkikoKeyboardEventKind
.
TYPE
,
UIEvent
()
event
)
)
}
}
...
@@ -34,10 +38,12 @@ fun toSkikoKeyboardEvent(
...
@@ -34,10 +38,12 @@ fun toSkikoKeyboardEvent(
event
:
UIPress
,
event
:
UIPress
,
kind
:
SkikoKeyboardEventKind
kind
:
SkikoKeyboardEventKind
):
SkikoKeyboardEvent
{
):
SkikoKeyboardEvent
{
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
return
SkikoKeyboardEvent
(
return
SkikoKeyboardEvent
(
SkikoKey
.
valueOf
(
event
.
key
!!
.
keyCode
),
SkikoKey
.
valueOf
(
event
.
key
!!
.
keyCode
),
toSkikoModifiers
(
event
),
toSkikoModifiers
(
event
),
kind
,
kind
,
timestamp
,
event
event
)
)
}
}
...
...
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
View file @
2d49c262
...
@@ -185,7 +185,8 @@ actual open class SkiaLayer {
...
@@ -185,7 +185,8 @@ actual open class SkiaLayer {
}
}
// TODO: do properly
// TODO: do properly
actual
typealias
SkikoTouchPlatformEvent
=
UITouch
actual
typealias
SkikoGesturePlatformEvent
=
UIEvent
actual
typealias
SkikoGesturePlatformEvent
=
UIEvent
actual
typealias
SkikoPlatformInputEvent
=
UI
Event
actual
typealias
SkikoPlatformInputEvent
=
UI
Press
actual
typealias
SkikoPlatformKeyboardEvent
=
UIPress
actual
typealias
SkikoPlatformKeyboardEvent
=
UIPress
actual
typealias
SkikoPlatformPointerEvent
=
UIEvent
actual
typealias
SkikoPlatformPointerEvent
=
UIEvent
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoViewController.kt
View file @
2d49c262
...
@@ -24,6 +24,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -24,6 +24,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
override
fun
canBecomeFirstResponder
()
=
true
override
fun
canBecomeFirstResponder
()
=
true
private
var
keyEvent
:
UIPress
?
=
null
private
var
inputText
:
String
=
""
private
var
inputText
:
String
=
""
override
fun
hasText
():
Boolean
{
override
fun
hasText
():
Boolean
{
return
inputText
.
length
>
0
return
inputText
.
length
>
0
...
@@ -31,7 +32,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -31,7 +32,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
override
fun
insertText
(
theText
:
String
)
{
override
fun
insertText
(
theText
:
String
)
{
inputText
+=
theText
inputText
+=
theText
skikoLayer
.
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
theText
))
skikoLayer
.
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
theText
,
keyEvent
))
}
}
override
fun
deleteBackward
()
{
override
fun
deleteBackward
()
{
...
@@ -41,8 +42,9 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -41,8 +42,9 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
override
fun
pressesBegan
(
presses
:
Set
<
*
>,
withEvent
:
UIPressesEvent
?)
{
override
fun
pressesBegan
(
presses
:
Set
<
*
>,
withEvent
:
UIPressesEvent
?)
{
if
(
withEvent
!=
null
)
{
if
(
withEvent
!=
null
)
{
for
(
press
in
withEvent
.
allPresses
)
{
for
(
press
in
withEvent
.
allPresses
)
{
keyEvent
=
press
as
UIPress
skikoLayer
.
skikoView
?.
onKeyboardEvent
(
skikoLayer
.
skikoView
?.
onKeyboardEvent
(
toSkikoKeyboardEvent
(
press
as
UIPress
,
SkikoKeyboardEventKind
.
DOWN
)
toSkikoKeyboardEvent
(
press
,
SkikoKeyboardEventKind
.
DOWN
)
)
)
}
}
}
}
...
@@ -52,8 +54,9 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -52,8 +54,9 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
override
fun
pressesEnded
(
presses
:
Set
<
*
>,
withEvent
:
UIPressesEvent
?)
{
override
fun
pressesEnded
(
presses
:
Set
<
*
>,
withEvent
:
UIPressesEvent
?)
{
if
(
withEvent
!=
null
)
{
if
(
withEvent
!=
null
)
{
for
(
press
in
withEvent
.
allPresses
)
{
for
(
press
in
withEvent
.
allPresses
)
{
keyEvent
=
press
as
UIPress
skikoLayer
.
skikoView
?.
onKeyboardEvent
(
skikoLayer
.
skikoView
?.
onKeyboardEvent
(
toSkikoKeyboardEvent
(
press
as
UIPress
,
SkikoKeyboardEventKind
.
UP
)
toSkikoKeyboardEvent
(
press
,
SkikoKeyboardEventKind
.
UP
)
)
)
}
}
}
}
...
@@ -62,20 +65,58 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -62,20 +65,58 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
override
fun
touchesBegan
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
override
fun
touchesBegan
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
withEvent
)
super
.
touchesBegan
(
touches
,
withEvent
)
val
sender
=
(
touches
.
elementAt
(
0
)
as
UITouch
)
val
events
:
MutableList
<
SkikoTouchEvent
>
=
mutableListOf
()
val
(
x
,
y
)
=
sender
.
locationInView
(
null
).
useContents
{
x
to
y
}
for
(
touch
in
touches
)
{
skikoLayer
.
skikoView
?.
onGestureEvent
(
val
event
=
touch
as
UITouch
SkikoGestureEvent
(
val
(
x
,
y
)
=
event
.
locationInView
(
null
).
useContents
{
x
to
y
}
x
=
x
,
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
y
=
y
,
events
.
add
(
kind
=
SkikoGestureEventKind
.
PRESS
,
SkikoTouchEvent
(
x
,
y
,
SkikoTouchEventKind
.
STARTED
,
timestamp
,
event
)
state
=
SkikoGestureEventState
.
PRESSED
)
)
)
}
}
skikoLayer
.
skikoView
?.
onTouchEvent
(
events
.
toTypedArray
())
}
override
fun
touchesEnded
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
override
fun
touchesEnded
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
)
super
.
touchesEnded
(
touches
,
withEvent
)
val
events
:
MutableList
<
SkikoTouchEvent
>
=
mutableListOf
()
for
(
touch
in
touches
)
{
val
event
=
touch
as
UITouch
val
(
x
,
y
)
=
event
.
locationInView
(
null
).
useContents
{
x
to
y
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
events
.
add
(
SkikoTouchEvent
(
x
,
y
,
SkikoTouchEventKind
.
ENDED
,
timestamp
,
event
)
)
}
skikoLayer
.
skikoView
?.
onTouchEvent
(
events
.
toTypedArray
())
}
override
fun
touchesMoved
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
super
.
touchesMoved
(
touches
,
withEvent
)
val
events
:
MutableList
<
SkikoTouchEvent
>
=
mutableListOf
()
for
(
touch
in
touches
)
{
val
event
=
touch
as
UITouch
val
(
x
,
y
)
=
event
.
locationInView
(
null
).
useContents
{
x
to
y
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
events
.
add
(
SkikoTouchEvent
(
x
,
y
,
SkikoTouchEventKind
.
MOVED
,
timestamp
,
event
)
)
}
skikoLayer
.
skikoView
?.
onTouchEvent
(
events
.
toTypedArray
())
}
override
fun
touchesCancelled
(
touches
:
Set
<
*
>,
withEvent
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
)
val
events
:
MutableList
<
SkikoTouchEvent
>
=
mutableListOf
()
for
(
touch
in
touches
)
{
val
event
=
touch
as
UITouch
val
(
x
,
y
)
=
event
.
locationInView
(
null
).
useContents
{
x
to
y
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
events
.
add
(
SkikoTouchEvent
(
x
,
y
,
SkikoTouchEventKind
.
CANCELLED
,
timestamp
,
event
)
)
}
skikoLayer
.
skikoView
?.
onTouchEvent
(
events
.
toTypedArray
())
}
}
internal
lateinit
var
appFactory
:
(
SkiaLayer
)
->
SkikoView
internal
lateinit
var
appFactory
:
(
SkiaLayer
)
->
SkikoView
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skiko/Convertors.js.kt
View file @
2d49c262
...
@@ -11,12 +11,13 @@ fun toSkikoEvent(
...
@@ -11,12 +11,13 @@ fun toSkikoEvent(
kind
:
SkikoPointerEventKind
kind
:
SkikoPointerEventKind
):
SkikoPointerEvent
{
):
SkikoPointerEvent
{
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
event
.
offsetX
,
x
=
event
.
offsetX
,
event
.
offsetY
,
y
=
event
.
offsetY
,
toSkikoMouseButtons
(
event
,
buttons
),
buttons
=
toSkikoMouseButtons
(
event
,
buttons
),
toSkikoModifiers
(
event
),
modifiers
=
toSkikoModifiers
(
event
),
kind
,
kind
=
kind
,
event
timestamp
=
event
.
timeStamp
.
toLong
(),
platform
=
event
)
)
}
}
...
@@ -24,12 +25,13 @@ fun toSkikoDragEvent(
...
@@ -24,12 +25,13 @@ fun toSkikoDragEvent(
event
:
MouseEvent
event
:
MouseEvent
):
SkikoPointerEvent
{
):
SkikoPointerEvent
{
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
event
.
offsetX
,
x
=
event
.
offsetX
,
event
.
offsetY
,
y
=
event
.
offsetY
,
toSkikoMouseButtons
(
event
,
true
),
buttons
=
toSkikoMouseButtons
(
event
,
true
),
toSkikoModifiers
(
event
),
modifiers
=
toSkikoModifiers
(
event
),
SkikoPointerEventKind
.
DRAG
,
kind
=
SkikoPointerEventKind
.
DRAG
,
event
timestamp
=
event
.
timeStamp
.
toLong
(),
platform
=
event
)
)
}
}
...
@@ -41,6 +43,7 @@ fun toSkikoEvent(
...
@@ -41,6 +43,7 @@ fun toSkikoEvent(
SkikoKey
.
valueOf
(
toSkikoKey
(
event
)),
SkikoKey
.
valueOf
(
toSkikoKey
(
event
)),
toSkikoModifiers
(
event
),
toSkikoModifiers
(
event
),
kind
,
kind
,
event
.
timeStamp
.
toLong
(),
event
event
)
)
}
}
...
@@ -50,12 +53,15 @@ fun toSkikoScrollEvent(
...
@@ -50,12 +53,15 @@ fun toSkikoScrollEvent(
buttons
:
Boolean
buttons
:
Boolean
):
SkikoPointerEvent
{
):
SkikoPointerEvent
{
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
event
.
deltaX
,
x
=
event
.
offsetX
,
event
.
deltaY
,
y
=
event
.
offsetY
,
toSkikoMouseButtons
(
event
,
buttons
),
deltaX
=
event
.
deltaX
,
toSkikoModifiers
(
event
),
deltaY
=
event
.
deltaY
,
SkikoPointerEventKind
.
SCROLL
,
buttons
=
toSkikoMouseButtons
(
event
,
buttons
),
event
modifiers
=
toSkikoModifiers
(
event
),
kind
=
SkikoPointerEventKind
.
SCROLL
,
timestamp
=
event
.
timeStamp
.
toLong
(),
platform
=
event
)
)
}
}
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skiko/SkiaLayer.js.kt
View file @
2d49c262
...
@@ -105,6 +105,7 @@ actual open class SkiaLayer {
...
@@ -105,6 +105,7 @@ actual open class SkiaLayer {
var
onContentScaleChanged
:
((
Float
)
->
Unit
)?
=
null
var
onContentScaleChanged
:
((
Float
)
->
Unit
)?
=
null
actual
typealias
SkikoTouchPlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoPlatformInputEvent
=
InputEvent
actual
typealias
SkikoPlatformInputEvent
=
InputEvent
actual
typealias
SkikoPlatformKeyboardEvent
=
KeyboardEvent
actual
typealias
SkikoPlatformKeyboardEvent
=
KeyboardEvent
...
...
skiko/src/linuxMain/kotlin/org/jetbrains/skiko/SkiaLayer.linux.kt
View file @
2d49c262
...
@@ -25,6 +25,7 @@ actual open class SkiaLayer {
...
@@ -25,6 +25,7 @@ actual open class SkiaLayer {
}
}
// TODO: do properly
// TODO: do properly
actual
typealias
SkikoTouchPlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoGesturePlatformEvent
=
Any
actual
typealias
SkikoPlatformInputEvent
=
Any
actual
typealias
SkikoPlatformInputEvent
=
Any
actual
typealias
SkikoPlatformKeyboardEvent
=
Any
actual
typealias
SkikoPlatformKeyboardEvent
=
Any
...
...
skiko/src/macosMain/kotlin/org/jetbrains/skiko/Convertors.macos.kt
View file @
2d49c262
...
@@ -15,13 +15,15 @@ fun toSkikoEvent(
...
@@ -15,13 +15,15 @@ fun toSkikoEvent(
view
.
frame
.
useContents
{
view
.
frame
.
useContents
{
ypos
=
size
.
height
-
ypos
ypos
=
size
.
height
-
ypos
}
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
xpos
,
x
=
xpos
,
ypos
,
y
=
ypos
,
toSkikoMouseButtons
(
event
,
kind
),
buttons
=
toSkikoMouseButtons
(
event
,
kind
),
toSkikoModifiers
(
event
),
modifiers
=
toSkikoModifiers
(
event
),
kind
,
kind
=
kind
,
event
timestamp
=
timestamp
,
platform
=
event
)
)
}
}
...
@@ -38,6 +40,7 @@ fun toSkikoEvent(
...
@@ -38,6 +40,7 @@ fun toSkikoEvent(
view
.
frame
.
useContents
{
view
.
frame
.
useContents
{
ypos
=
size
.
height
-
ypos
ypos
=
size
.
height
-
ypos
}
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
var
buttons
:
SkikoMouseButtons
var
buttons
:
SkikoMouseButtons
if
(
kind
==
SkikoPointerEventKind
.
DOWN
)
{
if
(
kind
==
SkikoPointerEventKind
.
DOWN
)
{
buttonsFlags
=
buttonsFlags
.
or
(
button
.
value
)
buttonsFlags
=
buttonsFlags
.
or
(
button
.
value
)
...
@@ -47,25 +50,38 @@ fun toSkikoEvent(
...
@@ -47,25 +50,38 @@ fun toSkikoEvent(
buttonsFlags
=
buttonsFlags
.
xor
(
button
.
value
)
buttonsFlags
=
buttonsFlags
.
xor
(
button
.
value
)
}
}
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
xpos
,
x
=
xpos
,
ypos
,
y
=
ypos
,
buttons
,
buttons
=
buttons
,
toSkikoModifiers
(
event
),
modifiers
=
toSkikoModifiers
(
event
),
kind
,
kind
=
kind
,
event
timestamp
=
timestamp
,
platform
=
event
)
)
}
}
fun
toSkikoScrollEvent
(
fun
toSkikoScrollEvent
(
event
:
NSEvent
event
:
NSEvent
,
view
:
NSView
):
SkikoPointerEvent
{
):
SkikoPointerEvent
{
var
(
xpos
,
ypos
)
=
event
.
locationInWindow
.
useContents
{
x
to
y
}
// Translate.
view
.
frame
.
useContents
{
ypos
=
size
.
height
-
ypos
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
return
SkikoPointerEvent
(
return
SkikoPointerEvent
(
event
.
deltaX
,
x
=
xpos
,
event
.
deltaY
,
y
=
ypos
,
SkikoMouseButtons
.
NONE
,
deltaX
=
event
.
deltaX
,
toSkikoModifiers
(
event
),
deltaY
=
event
.
deltaY
,
SkikoPointerEventKind
.
SCROLL
,
buttons
=
SkikoMouseButtons
.
NONE
,
event
modifiers
=
toSkikoModifiers
(
event
),
kind
=
SkikoPointerEventKind
.
SCROLL
,
timestamp
=
timestamp
,
platform
=
event
)
)
}
}
...
@@ -73,20 +89,26 @@ fun toSkikoEvent(
...
@@ -73,20 +89,26 @@ fun toSkikoEvent(
event
:
NSEvent
,
event
:
NSEvent
,
kind
:
SkikoKeyboardEventKind
kind
:
SkikoKeyboardEventKind
):
SkikoKeyboardEvent
{
):
SkikoKeyboardEvent
{
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
return
SkikoKeyboardEvent
(
return
SkikoKeyboardEvent
(
SkikoKey
.
valueOf
(
event
.
keyCode
.
toInt
()),
SkikoKey
.
valueOf
(
event
.
keyCode
.
toInt
()),
toSkikoModifiers
(
event
),
toSkikoModifiers
(
event
),
kind
,
kind
,
timestamp
,
event
event
)
)
}
}
fun
toSkikoTypeEvent
(
fun
toSkikoTypeEvent
(
character
:
String
,
character
:
String
,
event
:
NSEvent
,
event
:
NSEvent
?
,
):
SkikoInputEvent
{
):
SkikoInputEvent
{
val
key
=
if
(
event
!=
null
)
SkikoKey
.
valueOf
(
event
.
keyCode
.
toInt
())
else
SkikoKey
.
KEY_UNKNOWN
val
modifiers
=
if
(
event
!=
null
)
toSkikoModifiers
(
event
)
else
SkikoInputModifiers
.
EMPTY
return
SkikoInputEvent
(
return
SkikoInputEvent
(
character
,
character
,
key
,
modifiers
,
SkikoKeyboardEventKind
.
TYPE
,
SkikoKeyboardEventKind
.
TYPE
,
event
event
)
)
...
@@ -114,10 +136,12 @@ fun toSkikoEvent(
...
@@ -114,10 +136,12 @@ fun toSkikoEvent(
if
(
modifierKeyUpFlag
==
actionAllKeyUpFlag
)
{
if
(
modifierKeyUpFlag
==
actionAllKeyUpFlag
)
{
kind
=
SkikoKeyboardEventKind
.
UP
kind
=
SkikoKeyboardEventKind
.
UP
}
}
val
timestamp
=
(
event
.
timestamp
*
1
_000
).
toLong
()
return
SkikoKeyboardEvent
(
return
SkikoKeyboardEvent
(
SkikoKey
.
valueOf
(
event
.
keyCode
.
toInt
()),
SkikoKey
.
valueOf
(
event
.
keyCode
.
toInt
()),
toSkikoModifiers
(
event
),
toSkikoModifiers
(
event
),
kind
,
kind
,
timestamp
,
event
event
)
)
}
}
...
...
skiko/src/macosMain/kotlin/org/jetbrains/skiko/SkiaLayer.macos.kt
View file @
2d49c262
...
@@ -108,17 +108,19 @@ actual open class SkiaLayer() {
...
@@ -108,17 +108,19 @@ actual open class SkiaLayer() {
skikoView
?.
onPointerEvent
(
toSkikoEvent
(
event
,
SkikoPointerEventKind
.
DRAG
,
nsView
))
skikoView
?.
onPointerEvent
(
toSkikoEvent
(
event
,
SkikoPointerEventKind
.
DRAG
,
nsView
))
}
}
override
fun
scrollWheel
(
event
:
NSEvent
)
{
override
fun
scrollWheel
(
event
:
NSEvent
)
{
skikoView
?.
onPointerEvent
(
toSkikoScrollEvent
(
event
))
skikoView
?.
onPointerEvent
(
toSkikoScrollEvent
(
event
,
nsView
))
}
}
override
fun
keyDown
(
event
:
NSEvent
)
{
override
fun
keyDown
(
event
:
NSEvent
)
{
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
,
SkikoKeyboardEventKind
.
DOWN
))
keyEvent
=
event
keyEvent
=
event
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
,
SkikoKeyboardEventKind
.
DOWN
))
interpretKeyEvents
(
listOf
(
event
))
interpretKeyEvents
(
listOf
(
event
))
}
}
override
fun
flagsChanged
(
event
:
NSEvent
)
{
override
fun
flagsChanged
(
event
:
NSEvent
)
{
keyEvent
=
event
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
))
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
))
}
}
override
fun
keyUp
(
event
:
NSEvent
)
{
override
fun
keyUp
(
event
:
NSEvent
)
{
keyEvent
=
event
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
,
SkikoKeyboardEventKind
.
UP
))
skikoView
?.
onKeyboardEvent
(
toSkikoEvent
(
event
,
SkikoKeyboardEventKind
.
UP
))
}
}
...
@@ -151,7 +153,7 @@ actual open class SkiaLayer() {
...
@@ -151,7 +153,7 @@ actual open class SkiaLayer() {
}
else
{
}
else
{
character
=
string
as
String
character
=
string
as
String
}
}
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
character
,
keyEvent
!!
))
skikoView
?.
onInputEvent
(
toSkikoTypeEvent
(
character
,
keyEvent
))
}
}
override
fun
setMarkedText
(
string
:
Any
,
selectedRange
:
CValue
<
NSRange
>,
replacementRange
:
CValue
<
NSRange
>)
{
override
fun
setMarkedText
(
string
:
Any
,
selectedRange
:
CValue
<
NSRange
>,
replacementRange
:
CValue
<
NSRange
>)
{
if
(
string
is
NSAttributedString
)
{
if
(
string
is
NSAttributedString
)
{
...
@@ -232,6 +234,7 @@ actual open class SkiaLayer() {
...
@@ -232,6 +234,7 @@ actual open class SkiaLayer() {
}
}
// TODO: do properly
// TODO: do properly
actual
typealias
SkikoTouchPlatformEvent
=
NSEvent
actual
typealias
SkikoGesturePlatformEvent
=
NSEvent
actual
typealias
SkikoGesturePlatformEvent
=
NSEvent
actual
typealias
SkikoPlatformInputEvent
=
NSEvent
actual
typealias
SkikoPlatformInputEvent
=
NSEvent
actual
typealias
SkikoPlatformKeyboardEvent
=
NSEvent
actual
typealias
SkikoPlatformKeyboardEvent
=
NSEvent
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment