glimmer-dsl-tk 0.0.49 → 0.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 362c0a5cd2265930f395295435fd7d7b9cc63b20d3c68afba754a57bf6c6dd38
4
- data.tar.gz: c38b13a059e821f94de00fbb15c979f3fd4a9a8869d33fac0c0b39da38b25717
3
+ metadata.gz: 275b189ef447a6e367ee34c453b2e1b0e3764b7a6bfb44d505287b9aa2ae7918
4
+ data.tar.gz: f6a737cfc3db92a03bb0004cae4b9c3fe539c8550836a0bcff04d22519f9d3de
5
5
  SHA512:
6
- metadata.gz: 39de4985ef3f10898d7d45d6c336780ad9222e560e20b2d35832f649363fbf60db2d3a2831251c44ba2cc1ca7d34f4adfe3394198c7f95408664976937051a82
7
- data.tar.gz: 554fffc52441411d7cf81fd0baefb5ca0fbc3406a7f6b61e960599f684bb855a97abfa2892a01bd8ce9f0f0214a6d5664e403ff618ab53fe184c178b83471917
6
+ metadata.gz: de44c79d480b46078c796ca9bbb83a452c8f8a933f1444c8b83eba5b162e0b5bcbf39a44c63403451146172aeab831a39770a98575b0b715ae2e7e1fde2fac30
7
+ data.tar.gz: a33417fbf638f89b71db35778e9e7977a5c137af40334d26a0aa4e52cf399cb643babaad25ed2c49c75ab2898a9cbe35747beeaa66a8a454abb902c7fb359048
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.50
4
+
5
+ - Support manual binding of contextual menu by passing `bind: false` option (e.g. `menu(bind: false) {...}` as demonstrated in samples/hello/hello_contextual_menu.rb)
6
+ - Support binding multiple contextual menus (they show up consecutively unless there is conditional logic to control showing them individually)
7
+ - Update Hello, Contextual Menu! to add a comment and an example about manual menu binding
8
+ - Upgrade to glimmer 2.5.4
9
+
3
10
  ## 0.0.49
4
11
 
5
12
  - [API Breaking] Update menu bar support to require `menu_bar` keyword under `root` or `toplevel`
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.49
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.50
2
2
  ## MRI Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
4
4
  [![Ruby](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
@@ -183,7 +183,7 @@ gem install glimmer-dsl-tk
183
183
 
184
184
  Add the following to `Gemfile`:
185
185
  ```
186
- gem 'glimmer-dsl-tk', '0.0.49'
186
+ gem 'glimmer-dsl-tk', '0.0.50'
187
187
  ```
188
188
 
189
189
  And, then run:
@@ -3234,7 +3234,7 @@ root { |r|
3234
3234
  anchor 'center'
3235
3235
  }
3236
3236
 
3237
- menu {
3237
+ menu_bar {
3238
3238
  # Mac-specific application menu (right next to the Apple menu)
3239
3239
  if OS.mac?
3240
3240
  menu(:application) {
@@ -3521,6 +3521,8 @@ root { |r|
3521
3521
  anchor 'center'
3522
3522
  }
3523
3523
 
3524
+ # Contextual Menu is bound to mouse right-click (and CTRL-click on Mac) by default
3525
+ # (Read Comment Below for Alternative)
3524
3526
  menu {
3525
3527
  menu(label: 'Edit', underline: 0) {
3526
3528
  menu_item(label: 'Cut', underline: 2) {
@@ -3637,6 +3639,32 @@ root { |r|
3637
3639
  }
3638
3640
  }
3639
3641
  }
3642
+
3643
+ # You can replace `menu {` code with `menu(bind: false) {` if you want to bind manually,
3644
+ # which can be useful if you want to show menu at a specific location based on conditional logic.
3645
+ #
3646
+ # You can also repurpose a `menu_bar` as a contextual menu by declaring `@menu = menu_bar {` and
3647
+ # binding to mouse right-click.
3648
+ #
3649
+ # Example:
3650
+ #
3651
+ # @menu = menu(bind: false) {
3652
+ # menu(label: 'File', underline: 0) {
3653
+ # menu_item(label: 'Exit')
3654
+ # }
3655
+ # }
3656
+ # if OS.mac?
3657
+ # on('2') do |event|
3658
+ # @menu.popup(event.x_root, event.y_root)
3659
+ # end
3660
+ # on('Control-1') do |event|
3661
+ # @menu.popup(event.x_root, event.y_root)
3662
+ # end
3663
+ # else
3664
+ # on('3') do |event|
3665
+ # @menu.popup(event.x_root, event.y_root)
3666
+ # end
3667
+ # end
3640
3668
  }.open
3641
3669
  ```
3642
3670
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.49
1
+ 0.0.50
Binary file
@@ -36,12 +36,18 @@ module Glimmer
36
36
  when ToplevelProxy
37
37
  if @keyword == 'menu_bar'
38
38
  @parent_proxy.tk['menu'] = @tk
39
- else
39
+ elsif @options[:bind].nil? || @options[:bind]
40
40
  if OS.mac?
41
- @parent_proxy.tk.bind '2', proc{|x,y| tk.popup(x,y)}, "%X %Y"
42
- @parent_proxy.tk.bind 'Control-1', proc{|x,y| tk.popup(x,y)}, "%X %Y"
41
+ @parent_proxy.handle_listener('2') do |event|
42
+ popup(event.x_root, event.y_root)
43
+ end
44
+ @parent_proxy.handle_listener('Control-1') do |event|
45
+ popup(event.x_root, event.y_root)
46
+ end
43
47
  else
44
- @parent_proxy.tk.bind '3', proc{|x,y| tk.popup(x,y)}, "%X %Y"
48
+ @parent_proxy.handle_listener('3') do |event|
49
+ popup(event.x_root, event.y_root)
50
+ end
45
51
  end
46
52
  end
47
53
  end
@@ -37,6 +37,8 @@ root { |r|
37
37
  anchor 'center'
38
38
  }
39
39
 
40
+ # Contextual Menu is bound to mouse right-click (and CTRL-click on Mac) by default
41
+ # (Read Comment Below for Alternative)
40
42
  menu {
41
43
  menu(label: 'Edit', underline: 0) {
42
44
  menu_item(label: 'Cut', underline: 2) {
@@ -153,4 +155,30 @@ root { |r|
153
155
  }
154
156
  }
155
157
  }
158
+
159
+ # You can replace `menu {` code with `menu(bind: false) {` if you want to bind manually,
160
+ # which can be useful if you want to show menu at a specific location based on conditional logic.
161
+ #
162
+ # You can also repurpose a `menu_bar` as a contextual menu by declaring `@menu = menu_bar {` and
163
+ # binding to mouse right-click.
164
+ #
165
+ # Example:
166
+ #
167
+ # @menu = menu(bind: false) {
168
+ # menu(label: 'File', underline: 0) {
169
+ # menu_item(label: 'Exit')
170
+ # }
171
+ # }
172
+ # if OS.mac?
173
+ # on('2') do |event|
174
+ # @menu.popup(event.x_root, event.y_root)
175
+ # end
176
+ # on('Control-1') do |event|
177
+ # @menu.popup(event.x_root, event.y_root)
178
+ # end
179
+ # else
180
+ # on('3') do |event|
181
+ # @menu.popup(event.x_root, event.y_root)
182
+ # end
183
+ # end
156
184
  }.open
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.49
4
+ version: 0.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-05 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer