glimmer-dsl-tk 0.0.36 → 0.0.37

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: 808f3c088481b9a8feedbccfcab17a2b37046493141bcce5677871f90e28046e
4
- data.tar.gz: 1f433efd48c50a6b95f61cf8bae8617c44d8bbdfe9ee8b68e4c7d0bc868e5028
3
+ metadata.gz: 2454b5a3d7bd7159328cab0c0c82a4ebcdb54066bec28a1549e3cbca61d1bd8d
4
+ data.tar.gz: 7535984b2838617c7a40ee336c653e6c5c9029c7e49b3a4a13f1815897ecec8d
5
5
  SHA512:
6
- metadata.gz: 9e0e8067624c6493dbd33bd151b885da42e04a443ef702a65abd10578c47ae22fc12f19d114ce2c345aa9bfc57c3332fa90a6ec758b7606ad62a354363b8fa27
7
- data.tar.gz: c29b2b44399613bd15df154ee9986807ae121fcef57ff37448014ef36cc825fe6aa80e7ae28cee02d77cbdf15893ff82ea06390ca8e46394ccd6abffdeafb21a
6
+ metadata.gz: d377872669979a76bf149aec8683ade86fadd7efa50817abe4f8e582a0f3b53ac354759f3e7e6aa4e683fcd6296308eb7339c049718fcd7c673e4452f1052614
7
+ data.tar.gz: b321a3e34b16f9a1719797c51f25521a48c4c12ba39f92a730618dedc54f564754f24e73f60118023213583e3629c188643684cc7d326628613c982c0a87e7d0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.37
4
+
5
+ - Have `text` widget grab focus after every formatting modification in Hello, Text! (e.g. after clicking `B` for Bold)
6
+
3
7
  ## 0.0.36
4
8
 
5
9
  - Hello, Toplevel! (Custom Window and Custom Dialog)
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.36
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.37
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)
@@ -161,7 +161,7 @@ gem install glimmer-dsl-tk
161
161
 
162
162
  Add the following to `Gemfile`:
163
163
  ```
164
- gem 'glimmer-dsl-tk', '~> 0.0.36'
164
+ gem 'glimmer-dsl-tk', '~> 0.0.37'
165
165
  ```
166
166
 
167
167
  And, then run:
@@ -352,12 +352,12 @@ The `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org/gems/
352
352
  - `add_font_format(region_start, region_end, font_option, value)`
353
353
  - `remove_font_format(region_start, region_end, font_option, value)`
354
354
  - `toggle_font_format(region_start, region_end, font_option, value)`
355
- - `add_selection_format(option, value, no_selection_default: :insert_word)`: adds format to selection. If there is no selection, then applies format to current insert mark word.
356
- - `remove_selection_format(option, value, no_selection_default: :insert_word)`
357
- - `toggle_selection_format(option, value, no_selection_default: :insert_word)`: toggles format on selection. If there is no selection, then toggles format on current insert mark word.
358
- - `add_selection_font_format(font_option, value, no_selection_default: :insert_word)`
359
- - `remove_selection_font_format(font_option, value, no_selection_default: :insert_word)`
360
- - `toggle_selection_font_format(font_option, value, no_selection_default: :insert_word)`
355
+ - `add_selection_format(option, value, no_selection_default: :insert_word, focus: true)`: adds format to selection. If there is no selection, then applies format to current insert mark word.
356
+ - `remove_selection_format(option, value, no_selection_default: :insert_word, focus: true)`
357
+ - `toggle_selection_format(option, value, no_selection_default: :insert_word, focus: true)`: toggles format on selection. If there is no selection, then toggles format on current insert mark word.
358
+ - `add_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
359
+ - `remove_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
360
+ - `toggle_selection_font_format(font_option, value, no_selection_default: :insert_word, focus: true)`
361
361
  - `text#insert_image(text_index, *image_args)`: inserts image into `text` `value` content at `text_index` location (e.g. `'insert'`)
362
362
  - `text#get_open_file_to_insert_image(text_index = 'insert')`: opens a file dialog to select one of the available image formats and then inserts image into `text` `value` content
363
363
 
@@ -366,6 +366,9 @@ The `:no_selection_default` keyword arg to `*_selection_*` methods determines wh
366
366
  - `:insert_letter`: current letter for insert mark
367
367
  - `:none`: no behavior when no selection is in place
368
368
 
369
+ The `:focus` keyword arg defaults to `true` to indicate that the `text` widget should automatically grab focus after formatting modification.
370
+ Also, the `:focus` keyword arg can have an integer value representing number of milliseconds after which to grab focus once the formatting modification is done. This helps in special situations like when making the formatting modification from a combobox, which takes a while before relinquishing focus, so adding `100` millisecond delay helps ensure the `text` widget grabs focus after modification. Check [Hello, Text!](#hello-text) for an example of that.
371
+
369
372
  Available options:
370
373
 
371
374
  - `background`
@@ -2190,28 +2193,28 @@ class HelloText
2190
2193
 
2191
2194
  column_index = -1
2192
2195
 
2193
- combobox {
2196
+ combobox { |cb|
2194
2197
  grid row: 1, column: column_index += 1, column_weight: 1
2195
2198
  readonly true
2196
- text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
2199
+ text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value, focus: 100) }]
2197
2200
  }
2198
2201
 
2199
2202
  combobox {
2200
2203
  grid row: 1, column: column_index += 1, column_weight: 1
2201
2204
  readonly true
2202
- text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
2205
+ text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value, focus: 100) }]
2203
2206
  }
2204
2207
 
2205
2208
  combobox {
2206
2209
  grid row: 1, column: column_index += 1, column_weight: 1
2207
2210
  readonly true
2208
- text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
2211
+ text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value, focus: 100) }]
2209
2212
  }
2210
2213
 
2211
2214
  combobox {
2212
2215
  grid row: 1, column: column_index += 1, column_weight: 1
2213
2216
  readonly true
2214
- text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
2217
+ text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value, focus: 100) }]
2215
2218
  }
2216
2219
 
2217
2220
  separator {
@@ -2367,10 +2370,6 @@ class HelloText
2367
2370
  undo true
2368
2371
  value <=> [self, :document]
2369
2372
 
2370
- on('KeyPress') do |event|
2371
- show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
2372
- end
2373
-
2374
2373
  on('InsertMarkMoved') do
2375
2374
  self.font_family = @text.applied_font_format_value('family')
2376
2375
  self.font_size = @text.applied_font_format_value('size')
@@ -2383,6 +2382,10 @@ class HelloText
2383
2382
  @justify_center_button.default = @text.applied_format_value('justify') == 'center' ? 'active' : 'normal'
2384
2383
  @justify_right_button.default = @text.applied_format_value('justify') == 'right' ? 'active' : 'normal'
2385
2384
  end
2385
+
2386
+ on('KeyPress') do |event|
2387
+ show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
2388
+ end
2386
2389
  }
2387
2390
  }
2388
2391
  @root.open
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.36
1
+ 0.0.37
Binary file
@@ -92,31 +92,31 @@ module Glimmer
92
92
  end
93
93
  end
94
94
 
95
- def add_selection_format(option, value, no_selection_default: :insert_word)
96
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| add_format(range_start, range_end, option, value) }
95
+ def add_selection_format(option, value, no_selection_default: :insert_word, focus: true)
96
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| add_format(range_start, range_end, option, value) }
97
97
  end
98
98
 
99
- def remove_selection_format(option, value, no_selection_default: :insert_word)
100
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| remove_format(range_start, range_end, option, value) }
99
+ def remove_selection_format(option, value, no_selection_default: :insert_word, focus: true)
100
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| remove_format(range_start, range_end, option, value) }
101
101
  end
102
102
 
103
- def toggle_selection_format(option, value, no_selection_default: :insert_word)
104
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| toggle_format(range_start, range_end, option, value) }
103
+ def toggle_selection_format(option, value, no_selection_default: :insert_word, focus: true)
104
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| toggle_format(range_start, range_end, option, value) }
105
105
  end
106
106
 
107
- def add_selection_font_format(option, value, no_selection_default: :insert_word)
108
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| add_font_format(range_start, range_end, option, value) }
107
+ def add_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
108
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| add_font_format(range_start, range_end, option, value) }
109
109
  end
110
110
 
111
- def remove_selection_font_format(option, value, no_selection_default: :insert_word)
112
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| remove_font_format(range_start, range_end, option, value) }
111
+ def remove_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
112
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| remove_font_format(range_start, range_end, option, value) }
113
113
  end
114
114
 
115
- def toggle_selection_font_format(option, value, no_selection_default: :insert_word)
116
- process_selection_ranges(no_selection_default: no_selection_default) { |range_start, range_end| toggle_font_format(range_start, range_end, option, value) }
115
+ def toggle_selection_font_format(option, value, no_selection_default: :insert_word, focus: true)
116
+ process_selection_ranges(no_selection_default: no_selection_default, focus: focus) { |range_start, range_end| toggle_font_format(range_start, range_end, option, value) }
117
117
  end
118
118
 
119
- def process_selection_ranges(no_selection_default: :insert_word, &processor)
119
+ def process_selection_ranges(no_selection_default: :insert_word, focus: true, &processor)
120
120
  regions = @tk.tag_ranges('sel')
121
121
  if regions.empty?
122
122
  case no_selection_default
@@ -131,6 +131,11 @@ module Glimmer
131
131
  range_end = region.last
132
132
  processor.call(range_start, range_end)
133
133
  end
134
+ if focus == true
135
+ @tk.focus
136
+ elsif focus.is_a?(Integer)
137
+ ::Tk.after(focus) { @tk.focus }
138
+ end
134
139
  end
135
140
 
136
141
  def applied_format?(region_start, region_end, option, value)
@@ -109,28 +109,28 @@ class HelloText
109
109
 
110
110
  column_index = -1
111
111
 
112
- combobox {
112
+ combobox { |cb|
113
113
  grid row: 1, column: column_index += 1, column_weight: 1
114
114
  readonly true
115
- text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value) }]
115
+ text <=> [self, :font_family, after_write: ->(value) { @text.toggle_selection_font_format('family', value == FONT_FAMILY_PROMPT ? 'Courier New' : value, focus: 100) }]
116
116
  }
117
117
 
118
118
  combobox {
119
119
  grid row: 1, column: column_index += 1, column_weight: 1
120
120
  readonly true
121
- text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value) }]
121
+ text <=> [self, :font_size, after_write: ->(value) { @text.toggle_selection_font_format('size', value == FONT_SIZE_PROMPT ? 13 : value, focus: 100) }]
122
122
  }
123
123
 
124
124
  combobox {
125
125
  grid row: 1, column: column_index += 1, column_weight: 1
126
126
  readonly true
127
- text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value) }]
127
+ text <=> [self, :foreground, after_write: ->(value) { @text.add_selection_format('foreground', value == FOREGROUND_PROMPT ? 'black' : value, focus: 100) }]
128
128
  }
129
129
 
130
130
  combobox {
131
131
  grid row: 1, column: column_index += 1, column_weight: 1
132
132
  readonly true
133
- text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value) }]
133
+ text <=> [self, :background, after_write: ->(value) { @text.add_selection_format('background', value == BACKGROUND_PROMPT ? 'white' : value, focus: 100) }]
134
134
  }
135
135
 
136
136
  separator {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh