-
Notifications
You must be signed in to change notification settings - Fork 137
/
UIEventSource.kt
56 lines (50 loc) · 2.04 KB
/
UIEventSource.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package org.hexworks.zircon.api.uievent
import org.hexworks.cobalt.events.api.Subscription
/**
* An [UIEventSource] is an object which emits [UIEvent]s and can be used to listen to
* those events.
*/
interface UIEventSource {
/**
* Adds the given [handler] for mouse events. Use this if you selectively
* consume events.
*/
fun handleMouseEvents(
eventType: MouseEventType,
handler: (event: MouseEvent, phase: UIEventPhase) -> UIEventResponse
): Subscription
/**
* Adds the given [handler] for [MouseEvent]s. Differs from a [handleMouseEvents]
* in a way that its [handler] doesn't return an [UIEventResponse], but
* [Processed] is returned implicitly to the framework.
*
* Use [processMouseEvents] if you **always** handle the event
* (you never skip/drop events). This means that [processMouseEvents] can
* be used if you find yourself always returning [Processed] form your event listeners.
*/
fun processMouseEvents(
eventType: MouseEventType,
handler: (event: MouseEvent, phase: UIEventPhase) -> Unit
): Subscription
/**
* Adds the given [handler] for keyboard events. Use this if you selectively
* consume events.
*/
fun handleKeyboardEvents(
eventType: KeyboardEventType,
handler: (event: KeyboardEvent, phase: UIEventPhase) -> UIEventResponse
): Subscription
/**
* Adds the given [handler] for [KeyboardEvent]s. Differs from a [handleKeyboardEvents]
* in a way that its [handler] doesn't return an [UIEventResponse], but
* [Processed] is returned implicitly to the framework.
*
* Use [processKeyboardEvents] if you **always** handle the event
* (you never skip/drop events). This means that [processKeyboardEvents] can
* be used if you find yourself always returning [Processed] form your event listeners.
*/
fun processKeyboardEvents(
eventType: KeyboardEventType,
handler: (event: KeyboardEvent, phase: UIEventPhase) -> Unit
): Subscription
}