glimmer-dsl-opal 0.26.2 → 0.26.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/glimmer/swt/combo_proxy.rb +0 -39
- data/lib/glimmer/swt/date_time_proxy.rb +0 -37
- data/lib/glimmer/swt/display_proxy.rb +0 -109
- data/lib/glimmer/swt/spinner_proxy.rb +0 -39
- data/lib/glimmer/swt/text_proxy.rb +1 -39
- data/lib/glimmer/swt/widget_proxy.rb +130 -56
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cabde097ac994643d49e0af9b78fc1bbc7b2eb15857deb8741c557f4e676a4da
|
4
|
+
data.tar.gz: a198b93dc21bc2ea93e8542a84bbb83919be9ad0d63355f27dcf1fe4991b682c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b77f3a496e6dd8e8afea59185ba46306b07e9cb0e4fb5e41b97151886292ab1735008e5a58f08251874e25ede8b781f819498f2ef0c84ba4f357f8c13b7c2c0a
|
7
|
+
data.tar.gz: bc9646367d1cd6476f60edf98cf2a94ff24dd6bff14756b3bcbc1365e79a3cb22869c626bc897f94784c59e3cffe30fe5c5e8fe90915a23fc042d3b4f836ffae
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -145,7 +145,7 @@ Hello, Table! Game Booked
|
|
145
145
|
|
146
146
|
NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
147
147
|
|
148
|
-
**Alpha Version** 0.26.
|
148
|
+
**Alpha Version** 0.26.3 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
|
149
149
|
|
150
150
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
151
151
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -269,7 +269,7 @@ gem 'opal', '1.0.5'
|
|
269
269
|
gem 'opal-rails', '1.1.2'
|
270
270
|
gem 'opal-async', '~> 1.4.0'
|
271
271
|
gem 'opal-jquery', '~> 0.4.4'
|
272
|
-
gem 'glimmer-dsl-opal', '~> 0.26.
|
272
|
+
gem 'glimmer-dsl-opal', '~> 0.26.3'
|
273
273
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
274
274
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
275
275
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.26.
|
1
|
+
0.26.3
|
@@ -55,45 +55,6 @@ module Glimmer
|
|
55
55
|
}
|
56
56
|
}
|
57
57
|
},
|
58
|
-
'on_key_pressed' => {
|
59
|
-
event: 'keydown',
|
60
|
-
event_handler: -> (event_listener) {
|
61
|
-
-> (event) {
|
62
|
-
@last_key_pressed_event = event
|
63
|
-
@text = event.target.value
|
64
|
-
# TODO generalize this solution to all widgets that support key presses
|
65
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
66
|
-
event.define_singleton_method(:keyCode) {event.which}
|
67
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
68
|
-
event.define_singleton_method(:character) {event.which.chr}
|
69
|
-
event.define_singleton_method(:stateMask) do
|
70
|
-
state_mask = 0
|
71
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
72
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
73
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
74
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
75
|
-
state_mask
|
76
|
-
end
|
77
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
78
|
-
doit = true
|
79
|
-
event.define_singleton_method(:doit=) do |value|
|
80
|
-
doit = value
|
81
|
-
end
|
82
|
-
event.define_singleton_method(:doit) { doit }
|
83
|
-
event_listener.call(event)
|
84
|
-
|
85
|
-
# TODO Fix doit false, it's not stopping input
|
86
|
-
unless doit
|
87
|
-
event.prevent
|
88
|
-
event.prevent_default
|
89
|
-
event.stop_propagation
|
90
|
-
event.stop_immediate_propagation
|
91
|
-
end
|
92
|
-
|
93
|
-
doit
|
94
|
-
}
|
95
|
-
}
|
96
|
-
},
|
97
58
|
}
|
98
59
|
end
|
99
60
|
|
@@ -136,43 +136,6 @@ module Glimmer
|
|
136
136
|
}
|
137
137
|
},
|
138
138
|
],
|
139
|
-
'on_key_pressed' => {
|
140
|
-
event: 'keydown',
|
141
|
-
event_handler: -> (event_listener) {
|
142
|
-
-> (event) {
|
143
|
-
# TODO generalize this solution to all widgets that support key presses
|
144
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
145
|
-
event.define_singleton_method(:keyCode) {event.which}
|
146
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
147
|
-
event.define_singleton_method(:character) {event.which.chr}
|
148
|
-
event.define_singleton_method(:stateMask) do
|
149
|
-
state_mask = 0
|
150
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
151
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
152
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
153
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
154
|
-
state_mask
|
155
|
-
end
|
156
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
157
|
-
doit = true
|
158
|
-
event.define_singleton_method(:doit=) do |value|
|
159
|
-
doit = value
|
160
|
-
end
|
161
|
-
event.define_singleton_method(:doit) { doit }
|
162
|
-
event_listener.call(event)
|
163
|
-
|
164
|
-
# TODO Fix doit false, it's not stopping input
|
165
|
-
unless doit
|
166
|
-
event.prevent
|
167
|
-
event.prevent_default
|
168
|
-
event.stop_propagation
|
169
|
-
event.stop_immediate_propagation
|
170
|
-
end
|
171
|
-
|
172
|
-
doit
|
173
|
-
}
|
174
|
-
}
|
175
|
-
},
|
176
139
|
}
|
177
140
|
end
|
178
141
|
|
@@ -4,22 +4,6 @@ require 'glimmer/swt/swt_proxy'
|
|
4
4
|
module Glimmer
|
5
5
|
module SWT
|
6
6
|
class DisplayProxy < WidgetProxy
|
7
|
-
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP = {
|
8
|
-
16 => SWTProxy[:shift],
|
9
|
-
17 => SWTProxy[:ctrl],
|
10
|
-
18 => SWTProxy[:alt],
|
11
|
-
37 => SWTProxy[:arrow_left],
|
12
|
-
38 => SWTProxy[:arrow_up],
|
13
|
-
39 => SWTProxy[:arrow_right],
|
14
|
-
40 => SWTProxy[:arrow_down],
|
15
|
-
}
|
16
|
-
|
17
|
-
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP = {
|
18
|
-
1 => SWTProxy[:left],
|
19
|
-
2 => SWTProxy[:right],
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
7
|
class << self
|
24
8
|
def instance
|
25
9
|
@instance ||= new
|
@@ -102,99 +86,6 @@ module Glimmer
|
|
102
86
|
# sync_exec kept for API compatibility reasons
|
103
87
|
alias sync_exec async_exec
|
104
88
|
|
105
|
-
def observation_request_to_event_mapping
|
106
|
-
{
|
107
|
-
'on_swt_keydown' => [
|
108
|
-
{
|
109
|
-
event: 'keypress',
|
110
|
-
event_handler: -> (event_listener) {
|
111
|
-
-> (event) {
|
112
|
-
event.singleton_class.define_method(:character) do
|
113
|
-
which || key_code
|
114
|
-
end
|
115
|
-
event.define_singleton_method(:keyCode) {
|
116
|
-
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
117
|
-
}
|
118
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
119
|
-
event.define_singleton_method(:character) {event.which.chr}
|
120
|
-
event.define_singleton_method(:stateMask) do
|
121
|
-
state_mask = 0
|
122
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
123
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
124
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
125
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
126
|
-
state_mask
|
127
|
-
end
|
128
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
129
|
-
doit = true
|
130
|
-
event.define_singleton_method(:doit=) do |value|
|
131
|
-
doit = value
|
132
|
-
end
|
133
|
-
event.define_singleton_method(:doit) { doit }
|
134
|
-
event_listener.call(event)
|
135
|
-
|
136
|
-
# TODO Fix doit false, it's not stopping input
|
137
|
-
unless doit
|
138
|
-
event.prevent
|
139
|
-
event.prevent_default
|
140
|
-
event.stop_propagation
|
141
|
-
event.stop_immediate_propagation
|
142
|
-
end
|
143
|
-
|
144
|
-
doit
|
145
|
-
}
|
146
|
-
}
|
147
|
-
},
|
148
|
-
{
|
149
|
-
event: 'keydown',
|
150
|
-
event_handler: -> (event_listener) {
|
151
|
-
-> (event) {
|
152
|
-
original_event = event
|
153
|
-
event = ::Event.new(event)
|
154
|
-
event.define_singleton_method(:keyLocation) do
|
155
|
-
key_location = `#{original_event}.location`
|
156
|
-
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[key_location]
|
157
|
-
end
|
158
|
-
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
159
|
-
event.define_singleton_method(:character) do
|
160
|
-
which || key_code
|
161
|
-
end
|
162
|
-
event.define_singleton_method(:keyCode) {
|
163
|
-
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
164
|
-
}
|
165
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
166
|
-
event.define_singleton_method(:character) {event.which.chr}
|
167
|
-
event.define_singleton_method(:stateMask) do
|
168
|
-
state_mask = 0
|
169
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
170
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
171
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
172
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
173
|
-
state_mask
|
174
|
-
end
|
175
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
176
|
-
doit = true
|
177
|
-
event.define_singleton_method(:doit=) do |value|
|
178
|
-
doit = value
|
179
|
-
end
|
180
|
-
event.define_singleton_method(:doit) { doit }
|
181
|
-
event_listener.call(event) if event.which != 13 && (event.which == 127 || event.which <= 40)
|
182
|
-
|
183
|
-
# TODO Fix doit false, it's not stopping input
|
184
|
-
unless doit
|
185
|
-
event.prevent
|
186
|
-
event.prevent_default
|
187
|
-
event.stop_propagation
|
188
|
-
event.stop_immediate_propagation
|
189
|
-
end
|
190
|
-
doit
|
191
|
-
}
|
192
|
-
}
|
193
|
-
}
|
194
|
-
]
|
195
|
-
}
|
196
|
-
end
|
197
|
-
|
198
89
|
private
|
199
90
|
|
200
91
|
def async_exec_queues
|
@@ -153,45 +153,6 @@ module Glimmer
|
|
153
153
|
}
|
154
154
|
}
|
155
155
|
},
|
156
|
-
'on_key_pressed' => {
|
157
|
-
event: 'keydown',
|
158
|
-
event_handler: -> (event_listener) {
|
159
|
-
-> (event) {
|
160
|
-
@last_key_pressed_event = event
|
161
|
-
self.text = event.target.value
|
162
|
-
# TODO generalize this solution to all widgets that support key presses
|
163
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
164
|
-
event.define_singleton_method(:keyCode) {event.which}
|
165
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
166
|
-
event.define_singleton_method(:character) {event.which.chr}
|
167
|
-
event.define_singleton_method(:stateMask) do
|
168
|
-
state_mask = 0
|
169
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
170
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
171
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
172
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
173
|
-
state_mask
|
174
|
-
end
|
175
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
176
|
-
doit = true
|
177
|
-
event.define_singleton_method(:doit=) do |value|
|
178
|
-
doit = value
|
179
|
-
end
|
180
|
-
event.define_singleton_method(:doit) { doit }
|
181
|
-
event_listener.call(event)
|
182
|
-
|
183
|
-
# TODO Fix doit false, it's not stopping input
|
184
|
-
unless doit
|
185
|
-
event.prevent
|
186
|
-
event.prevent_default
|
187
|
-
event.stop_propagation
|
188
|
-
event.stop_immediate_propagation
|
189
|
-
end
|
190
|
-
|
191
|
-
doit
|
192
|
-
}
|
193
|
-
}
|
194
|
-
},
|
195
156
|
}
|
196
157
|
end
|
197
158
|
|
@@ -21,6 +21,7 @@ module Glimmer
|
|
21
21
|
event_handler: -> (event_listener) {
|
22
22
|
-> (event) {
|
23
23
|
# TODO consider unifying this event handler with on_key_pressed by relying on its result instead of hooking another keyup event
|
24
|
+
# TODO add all attributes for on_modify_text modify event
|
24
25
|
if @last_key_pressed_event.nil? || @last_key_pressed_event.doit
|
25
26
|
@text = event.target.value
|
26
27
|
event_listener.call(event)
|
@@ -34,45 +35,6 @@ module Glimmer
|
|
34
35
|
}
|
35
36
|
}
|
36
37
|
},
|
37
|
-
'on_key_pressed' => {
|
38
|
-
event: 'keydown',
|
39
|
-
event_handler: -> (event_listener) {
|
40
|
-
-> (event) {
|
41
|
-
@last_key_pressed_event = event
|
42
|
-
@text = event.target.value
|
43
|
-
# TODO generalize this solution to all widgets that support key presses
|
44
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
45
|
-
event.define_singleton_method(:keyCode) {event.which}
|
46
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
47
|
-
event.define_singleton_method(:character) {event.which.chr}
|
48
|
-
event.define_singleton_method(:stateMask) do
|
49
|
-
state_mask = 0
|
50
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
51
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
52
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
53
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
54
|
-
state_mask
|
55
|
-
end
|
56
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
57
|
-
doit = true
|
58
|
-
event.define_singleton_method(:doit=) do |value|
|
59
|
-
doit = value
|
60
|
-
end
|
61
|
-
event.define_singleton_method(:doit) { doit }
|
62
|
-
event_listener.call(event)
|
63
|
-
|
64
|
-
# TODO Fix doit false, it's not stopping input
|
65
|
-
unless doit
|
66
|
-
event.prevent
|
67
|
-
event.prevent_default
|
68
|
-
event.stop_propagation
|
69
|
-
event.stop_immediate_propagation
|
70
|
-
end
|
71
|
-
|
72
|
-
doit
|
73
|
-
}
|
74
|
-
}
|
75
|
-
},
|
76
38
|
}
|
77
39
|
end
|
78
40
|
|
@@ -32,7 +32,24 @@ module Glimmer
|
|
32
32
|
include PropertyOwner
|
33
33
|
|
34
34
|
Event = Struct.new(:widget, keyword_init: true)
|
35
|
+
|
36
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP = {
|
37
|
+
16 => SWTProxy[:shift],
|
38
|
+
17 => SWTProxy[:ctrl],
|
39
|
+
18 => SWTProxy[:alt],
|
40
|
+
37 => SWTProxy[:arrow_left],
|
41
|
+
38 => SWTProxy[:arrow_up],
|
42
|
+
39 => SWTProxy[:arrow_right],
|
43
|
+
40 => SWTProxy[:arrow_down],
|
44
|
+
}
|
35
45
|
|
46
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP = {
|
47
|
+
0 => SWTProxy[:none],
|
48
|
+
1 => SWTProxy[:left],
|
49
|
+
2 => SWTProxy[:right],
|
50
|
+
3 => SWTProxy[:keypad],
|
51
|
+
}
|
52
|
+
|
36
53
|
SWT_CURSOR_TO_CSS_CURSOR_MAP = {
|
37
54
|
wait: 'wait',
|
38
55
|
sizenwse: 'nwse-resize',
|
@@ -373,7 +390,6 @@ module Glimmer
|
|
373
390
|
mouse_event_handler = -> (event_listener) {
|
374
391
|
-> (event) {
|
375
392
|
# TODO generalize this solution to all widgets that support key presses
|
376
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
377
393
|
event.define_singleton_method(:widget) {myself}
|
378
394
|
event.define_singleton_method(:button, &event.method(:which))
|
379
395
|
event.define_singleton_method(:count) {1} # TODO support double-click count of 2 in the future by using ondblclick
|
@@ -401,7 +417,6 @@ module Glimmer
|
|
401
417
|
mouse_move_event_handler = -> (event_listener) {
|
402
418
|
-> (event) {
|
403
419
|
# TODO generalize this solution to all widgets that support key presses
|
404
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
405
420
|
event.define_singleton_method(:widget) {myself}
|
406
421
|
event.define_singleton_method(:button, &event.method(:which))
|
407
422
|
event.define_singleton_method(:count) {1} # TODO support double-click count of 2 in the future by using ondblclick
|
@@ -426,7 +441,6 @@ module Glimmer
|
|
426
441
|
context_menu_handler = -> (event_listener) {
|
427
442
|
-> (event) {
|
428
443
|
# TODO generalize this solution to all widgets that support key presses
|
429
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
430
444
|
event.define_singleton_method(:widget) {myself}
|
431
445
|
event.define_singleton_method(:button, &event.method(:which))
|
432
446
|
event.define_singleton_method(:count) {1} # TODO support double-click count of 2 in the future by using ondblclick
|
@@ -507,10 +521,15 @@ module Glimmer
|
|
507
521
|
event: 'keypress',
|
508
522
|
event_handler: -> (event_listener) {
|
509
523
|
-> (event) {
|
510
|
-
# TODO generalize this solution to all widgets that support key presses
|
511
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
512
524
|
event.define_singleton_method(:widget) {myself}
|
513
|
-
event.define_singleton_method(:
|
525
|
+
event.define_singleton_method(:keyLocation) do
|
526
|
+
location = `#{event.to_n}.originalEvent.location`
|
527
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[location] || location
|
528
|
+
end
|
529
|
+
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
530
|
+
event.define_singleton_method(:keyCode) {
|
531
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
532
|
+
}
|
514
533
|
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
515
534
|
event.define_singleton_method(:character) {event.which.chr}
|
516
535
|
event.define_singleton_method(:stateMask) do
|
@@ -541,50 +560,18 @@ module Glimmer
|
|
541
560
|
}
|
542
561
|
} },
|
543
562
|
'on_key_released' => {
|
544
|
-
event: '
|
563
|
+
event: 'keyup',
|
545
564
|
event_handler: -> (event_listener) {
|
546
565
|
-> (event) {
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
event.define_singleton_method(:keyCode) {event.which}
|
551
|
-
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
552
|
-
event.define_singleton_method(:character) {event.which.chr}
|
553
|
-
event.define_singleton_method(:stateMask) do
|
554
|
-
state_mask = 0
|
555
|
-
state_mask |= SWTProxy[:alt] if event.alt_key
|
556
|
-
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
557
|
-
state_mask |= SWTProxy[:shift] if event.shift_key
|
558
|
-
state_mask |= SWTProxy[:command] if event.meta_key
|
559
|
-
state_mask
|
560
|
-
end
|
561
|
-
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
562
|
-
doit = true
|
563
|
-
event.define_singleton_method(:doit=) do |value|
|
564
|
-
doit = value
|
565
|
-
end
|
566
|
-
event.define_singleton_method(:doit) { doit }
|
567
|
-
event_listener.call(event)
|
568
|
-
|
569
|
-
# TODO Fix doit false, it's not stopping input
|
570
|
-
unless doit
|
571
|
-
event.prevent
|
572
|
-
event.prevent_default
|
573
|
-
event.stop_propagation
|
574
|
-
event.stop_immediate_propagation
|
566
|
+
event.define_singleton_method(:keyLocation) do
|
567
|
+
location = `#{event.to_n}.originalEvent.location`
|
568
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[location] || location
|
575
569
|
end
|
576
|
-
|
577
|
-
doit
|
578
|
-
}
|
579
|
-
} },
|
580
|
-
'on_swt_keydown' => {
|
581
|
-
event: 'keypress',
|
582
|
-
event_handler: -> (event_listener) {
|
583
|
-
-> (event) {
|
584
|
-
# TODO generalize this solution to all widgets that support key presses
|
585
|
-
# TODO support event.location once DOM3 is supported by opal-jquery
|
570
|
+
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
586
571
|
event.define_singleton_method(:widget) {myself}
|
587
|
-
event.define_singleton_method(:keyCode) {
|
572
|
+
event.define_singleton_method(:keyCode) {
|
573
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
574
|
+
}
|
588
575
|
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
589
576
|
event.define_singleton_method(:character) {event.which.chr}
|
590
577
|
event.define_singleton_method(:stateMask) do
|
@@ -613,15 +600,106 @@ module Glimmer
|
|
613
600
|
|
614
601
|
doit
|
615
602
|
}
|
616
|
-
}
|
603
|
+
}
|
604
|
+
},
|
605
|
+
'on_swt_keydown' => [
|
606
|
+
{
|
607
|
+
event: 'keypress',
|
608
|
+
event_handler: -> (event_listener) {
|
609
|
+
-> (event) {
|
610
|
+
event.define_singleton_method(:keyLocation) do
|
611
|
+
location = `#{event.to_n}.originalEvent.location`
|
612
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[location] || location
|
613
|
+
end
|
614
|
+
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
615
|
+
event.define_singleton_method(:keyCode) {
|
616
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
617
|
+
}
|
618
|
+
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
619
|
+
event.define_singleton_method(:character) {event.which.chr}
|
620
|
+
event.define_singleton_method(:stateMask) do
|
621
|
+
state_mask = 0
|
622
|
+
state_mask |= SWTProxy[:alt] if event.alt_key
|
623
|
+
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
624
|
+
state_mask |= SWTProxy[:shift] if event.shift_key
|
625
|
+
state_mask |= SWTProxy[:command] if event.meta_key
|
626
|
+
state_mask
|
627
|
+
end
|
628
|
+
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
629
|
+
doit = true
|
630
|
+
event.define_singleton_method(:doit=) do |value|
|
631
|
+
doit = value
|
632
|
+
end
|
633
|
+
event.define_singleton_method(:doit) { doit }
|
634
|
+
event_listener.call(event)
|
635
|
+
|
636
|
+
# TODO Fix doit false, it's not stopping input
|
637
|
+
unless doit
|
638
|
+
event.prevent
|
639
|
+
event.prevent_default
|
640
|
+
event.stop_propagation
|
641
|
+
event.stop_immediate_propagation
|
642
|
+
end
|
643
|
+
|
644
|
+
doit
|
645
|
+
}
|
646
|
+
}
|
647
|
+
},
|
648
|
+
{
|
649
|
+
event: 'keydown',
|
650
|
+
event_handler: -> (event_listener) {
|
651
|
+
-> (event) {
|
652
|
+
event.define_singleton_method(:keyLocation) do
|
653
|
+
location = `#{event.to_n}.originalEvent.location`
|
654
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[location] || location
|
655
|
+
end
|
656
|
+
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
657
|
+
event.define_singleton_method(:keyCode) {
|
658
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
659
|
+
}
|
660
|
+
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
661
|
+
event.define_singleton_method(:character) {event.which.chr}
|
662
|
+
event.define_singleton_method(:stateMask) do
|
663
|
+
state_mask = 0
|
664
|
+
state_mask |= SWTProxy[:alt] if event.alt_key
|
665
|
+
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
666
|
+
state_mask |= SWTProxy[:shift] if event.shift_key
|
667
|
+
state_mask |= SWTProxy[:command] if event.meta_key
|
668
|
+
state_mask
|
669
|
+
end
|
670
|
+
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
671
|
+
doit = true
|
672
|
+
event.define_singleton_method(:doit=) do |value|
|
673
|
+
doit = value
|
674
|
+
end
|
675
|
+
event.define_singleton_method(:doit) { doit }
|
676
|
+
event_listener.call(event) if event.which != 13 && (event.which == 127 || event.which <= 40)
|
677
|
+
|
678
|
+
# TODO Fix doit false, it's not stopping input
|
679
|
+
unless doit
|
680
|
+
event.prevent
|
681
|
+
event.prevent_default
|
682
|
+
event.stop_propagation
|
683
|
+
event.stop_immediate_propagation
|
684
|
+
end
|
685
|
+
doit
|
686
|
+
}
|
687
|
+
}
|
688
|
+
}
|
689
|
+
],
|
617
690
|
'on_swt_keyup' => {
|
618
|
-
event: '
|
691
|
+
event: 'keyup',
|
619
692
|
event_handler: -> (event_listener) {
|
620
693
|
-> (event) {
|
621
|
-
|
622
|
-
|
694
|
+
event.define_singleton_method(:keyLocation) do
|
695
|
+
location = `#{event.to_n}.originalEvent.location`
|
696
|
+
JS_LOCATION_TO_SWT_KEY_LOCATION_MAP[location] || location
|
697
|
+
end
|
698
|
+
event.define_singleton_method(:key_location, &event.method(:keyLocation))
|
623
699
|
event.define_singleton_method(:widget) {myself}
|
624
|
-
event.define_singleton_method(:keyCode) {
|
700
|
+
event.define_singleton_method(:keyCode) {
|
701
|
+
JS_KEY_CODE_TO_SWT_KEY_CODE_MAP[event.which] || event.which
|
702
|
+
}
|
625
703
|
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
626
704
|
event.define_singleton_method(:character) {event.which.chr}
|
627
705
|
event.define_singleton_method(:stateMask) do
|
@@ -800,11 +878,7 @@ module Glimmer
|
|
800
878
|
end
|
801
879
|
the_listener_dom_element = event_element_css_selector ? Element[event_element_css_selector] : listener_dom_element
|
802
880
|
unless the_listener_dom_element.empty?
|
803
|
-
|
804
|
-
`document.addEventListener('keydown', #{async_event_listener})`
|
805
|
-
else
|
806
|
-
the_listener_dom_element.on(event, &async_event_listener)
|
807
|
-
end
|
881
|
+
the_listener_dom_element.on(event, &async_event_listener)
|
808
882
|
# TODO ensure uniqueness of insertion (perhaps adding equals/hash method to event listener proxy)
|
809
883
|
|
810
884
|
event_listener_proxies << EventListenerProxy.new(element_proxy: self, selector: selector, dom_element: the_listener_dom_element, event: event, listener: async_event_listener, original_event_listener: original_event_listener)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|