Tk Source Code

View Ticket
Login
Ticket UUID: 2e07480f5f43ecaf67a8eeb40325a125779cb188
Title: ttk::spinbox needs to document <MouseWheel> binding
Type: Bug Version: 8.6.10
Submitter: anonymous Created on: 2020-05-28 03:27:28
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2020-06-23 21:58:49
Resolution: None Closed By: nobody
    Closed on:
Description:

The manual for ttk::spinbox does not list the additional binding for the Mouse Wheel. Presumably, it is depending on ttk::entry's manual section on default bindings to suffice.

In addition, since the Mouse Wheel does not need focus to work on a widget, rather it sends its events to the widget under the mouse pointer, it is possible for a user to accidentally change a ttk::spinbox while trying to scroll in some other window. For that reason, the programmer might wish to disable the wheel behavior. I propose that an additional section on "default bindings" be added to ttk::spinbox manual entry. Here's an example of what I think might be useful:

Default Bindings

Being an extended ttk::entry widget, ttk::spinbox includes all the default bindings mentioned in ttk::entry, plus the following:

1. Mouse wheel rotates are the same as pressing <Up> and <Down>. In addition, a mouse with a tilt wheel found on some hardware acts like a shift rotate.

If this is not desired, the following can be used for a ttk::spinbox named .spin to disable this behavior:

bind .spin <MouseWheel> break

The following will leave the mouse wheel rotate active but disable the tilt-wheel or the wheel with the shift key down.

bind .spin <Shift-MouseWheel> break

2... (if there's any others that differ from ttk::entry, otherwise numbering not needed)

User Comments: bll added on 2020-06-23 21:58:49:
There are some mouse bindings that could be fixed also.
See: https://core.tcl-lang.org/tk/info/8f2c972b3abc8531

fvogel added on 2020-06-23 20:34:08:

In reality there are several differences in the bindings between ttk::entry and ttk::spinbox, not just the added MouseWheel. One cannot just say "ttk::spinbox includes all the default bindings mentioned in ttk::entry, plus [...]".

Try for yourself by fiddling with text in the two following widgets:

  package require Tk
  pack [ttk::spinbox .s -from 1 -to 100]
  pack [ttk::entry .e]

Apart from MouseWheel here are the differences I have found by testing on a Windows box. The ttk::entry text from the "Default bindings" section in the man mage is the bulleted text; the ttk::spinbox would be the --> text; and italics denotes a comment:

  • Double-clicking with mouse button 1 selects the word under the mouse and positions the insert cursor at the end of the word. Dragging after a double click strokes out a selection consisting of whole words.

--> Double-clicking with mouse button 1 selects all of the text in the spinbox and positions the insert cursor at the end of the line.

  • Triple-clicking with mouse button 1 selects all of the text in the entry and positions the insert cursor at the end of the line.

--> Feature does not exist for ttk::spinbox

  • The ends of the selection can be adjusted by dragging with mouse button 1 while the Shift key is down. If the button is double-clicked before dragging then the selection will be adjusted in units of whole words.

--> The ends of the selection can be adjusted by dragging with mouse button 1 while the Shift key is down.

  • The Left and Right keys move the insert cursor one character to the left or right; they also clear any selection in the entry. If Left or Right is typed with the Shift key down, then the insertion cursor moves and the selection is extended to include the new character. Control-Left and Control-Right move the insert cursor by words, and Control-Shift-Left and Control-Shift-Right move the insert cursor by words and also extend the selection. Control-b and Control-f behave the same as Left and Right, respectively.

--> Control-b and Control-f do nothing in both ttk::entry and ttk::spinbox

  • The Home key and Control-a move the insert cursor to the beginning of the entry and clear any selection in the entry. Shift-Home moves the insert cursor to the beginning of the entry and extends the selection to that point.

--> Control-a does not move the insert cursor but selects all text, in both ttk::entry and ttk::spinbox

  • The End key and Control-e move the insert cursor to the end of the entry and clear any selection in the entry. Shift-End moves the cursor to the end and extends the selection to that point.

--> Control-e does nothing in both ttk::entry and ttk::spinbox

  • Control-\ clears any selection in the entry. --> I cannot test this with my french keyboard


fvogel added on 2020-05-28 20:23:11:

Reference of the full discussion on comp.lang.tcl.