-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactors.red
45 lines (37 loc) · 1.22 KB
/
actors.red
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
Red [
title: "Actors support for Draw-based widgets"
author: @hiiamboris
license: BSD-3
notes: {
A defined actor does NOT by default stop the evaluation of standard event handler.
This is so actors don't accidentally disable any internal functionality.
When required though, they can use STOP, e.g. for stopping tabbing.
}
]
;; requires events
actors: context [
supported-events: [
down up mid-down mid-up alt-down alt-up aux-down aux-up
dbl-click over wheel
key key-down key-up enter
focus unfocus click ;-- internally generated
time
]
actor-names: make map! map-each/eval name supported-events [ ;-- used to avoid frequent allocations when adding "on-"
[name to word! rejoin ["on-" name]]
]
;; previewer so it takes priority over event handlers and can stop them
register-previewer supported-events function [
space [object! none!] path [block!] event [map!] delay [percent! none!]
][
all [
space
actors: select space 'actors
name: select actor-names event/type
actor: select actors name
actor space path event delay
]
; if event/type <> 'time [print [event/type mold path] ??~ space]
; if event/type = 'key [print [event/type mold path] ??~ actors]
]
];; actors