glimmer-dsl-opal 0.26.1 → 0.26.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1bec8104295a4c2f4a5b3f6d1464c9e0b0f5175092e93b7dd9508a5c4feabd0
4
- data.tar.gz: 778f2026c647b7454d0586cf2310297d143d122a4b8937ec6189abdba260667d
3
+ metadata.gz: dd9df390a04a8efb59afa0dcfe42a88d3a2ebcc89b19f51b5daf325e85495898
4
+ data.tar.gz: f842142ce4346af198197cacaa1695eddc9f15f684c4b4250ebed41872d9253f
5
5
  SHA512:
6
- metadata.gz: 33e3f1b4bd51b3cfdc34d9f24403bb47d0a889c235e169232a3e8b8dae6db26617110dd55f8ed4a40d752c2e5f60569ea70c2b95db7a4435f1a2fddac25e3d7f
7
- data.tar.gz: 8fafbadda7e92fcf19ac96b994e3dcb67ed25febcdd521a97e94f57a66f272312cbc6763a341c30b1f1cf46e27ff62928eaed02cf8f1aa91c72590794e6ec7ee
6
+ metadata.gz: 1090a9d0bf0cab0bb673e32ce5711e3d034866e4d195995db125b40a43fa798f09f6944ba2e2bfbb38d06731248717bc38fd166d50c543e6271564aa8e80f978
7
+ data.tar.gz: 57e6aa38f7829508d5a6f0a54814ada1d58c79fda05f56d353a069271960727b9d92c2bb642839215a6942958d267d00e9befc7b5f688755037fe46fcd7b8f53
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.26.2
4
+
5
+ - Support key_event.key_location to distinguish between left and right alt/shift/command/ctrl buttons
6
+ - Use right/left alt/shift keys in Tetris for rotate right and rotate left
7
+
3
8
  ## 0.26.1
4
9
 
5
10
  - Support display on_swt_keydown event keyCode/key_code values for arrow keys and alt/shift/ctrl
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.1 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))
148
+ **Alpha Version** 0.26.2 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.1'
272
+ gem 'glimmer-dsl-opal', '~> 0.26.2'
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
1
+ 0.26.2
@@ -13,6 +13,12 @@ module Glimmer
13
13
  39 => SWTProxy[:arrow_right],
14
14
  40 => SWTProxy[:arrow_down],
15
15
  }
16
+
17
+ JS_LOCATION_TO_SWT_KEY_LOCATION_MAP = {
18
+ 1 => SWTProxy[:left],
19
+ 2 => SWTProxy[:right],
20
+ }
21
+
16
22
 
17
23
  class << self
18
24
  def instance
@@ -143,7 +149,14 @@ module Glimmer
143
149
  event: 'keydown',
144
150
  event_handler: -> (event_listener) {
145
151
  -> (event) {
146
- event.singleton_class.define_method(:character) do
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
147
160
  which || key_code
148
161
  end
149
162
  event.define_singleton_method(:keyCode) {
@@ -174,7 +187,6 @@ module Glimmer
174
187
  event.stop_propagation
175
188
  event.stop_immediate_propagation
176
189
  end
177
-
178
190
  doit
179
191
  }
180
192
  }
@@ -800,7 +800,11 @@ module Glimmer
800
800
  end
801
801
  the_listener_dom_element = event_element_css_selector ? Element[event_element_css_selector] : listener_dom_element
802
802
  unless the_listener_dom_element.empty?
803
- the_listener_dom_element.on(event, &async_event_listener)
803
+ if is_a?(DisplayProxy) && event == 'keydown'
804
+ `document.addEventListener('keydown', #{async_event_listener})`
805
+ else
806
+ the_listener_dom_element.on(event, &async_event_listener)
807
+ end
804
808
  # TODO ensure uniqueness of insertion (perhaps adding equals/hash method to event listener proxy)
805
809
 
806
810
  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)
@@ -72,8 +72,13 @@ class Tetris
72
72
  when 'e'.bytes.first
73
73
  game.rotate!(:right)
74
74
  when swt(:shift), swt(:alt)
75
- game.rotate!(:right)
75
+ if key_event.keyLocation == swt(:right) # right key
76
+ game.rotate!(:right)
77
+ elsif key_event.keyLocation == swt(:left) # left key
78
+ game.rotate!(:left)
79
+ end
76
80
  end
81
+
77
82
  end
78
83
  }
79
84
  end
@@ -142,7 +147,7 @@ class Tetris
142
147
  def show_about_dialog
143
148
  message_box {
144
149
  text 'Glimmer Tetris'
145
- message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\n for Left, Down, Right, Up\n\nCopyright (c) 2007-2021 Andy Maleh"
150
+ message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nUse arrow keys for movement\nand right/left alt/shift keys for rotation\nAlternatively:\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\n for Left, Down, Right, Up\n\nCopyright (c) 2007-2021 Andy Maleh"
146
151
  }.open
147
152
  end
148
153
  end
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.1
4
+ version: 0.26.2
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-24 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer