diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-08 06:23:40 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-08 06:23:40 (GMT) |
commit | dc2c36cea500db6933ade16c3252cef0a66ab26d (patch) | |
tree | 0b7650bc7c53e1dca25ec6facfe279368c9046a6 | |
parent | 6f2824501d0987043c6456d5ab00adbb4300b682 (diff) | |
download | tk-dc2c36cea500db6933ade16c3252cef0a66ab26d.zip tk-dc2c36cea500db6933ade16c3252cef0a66ab26d.tar.gz tk-dc2c36cea500db6933ade16c3252cef0a66ab26d.tar.bz2 |
Simplify throughout: ButtonPress -> Button, KeyPress -> Key (or remove it because it is the default anyway)
Use 'in' operator in stead of 'lsearch -exact' when possible
-rw-r--r-- | library/clrpick.tcl | 6 | ||||
-rw-r--r-- | library/console.tcl | 2 | ||||
-rw-r--r-- | library/demos/knightstour.tcl | 2 | ||||
-rw-r--r-- | library/fontchooser.tcl | 2 | ||||
-rw-r--r-- | library/listbox.tcl | 6 | ||||
-rw-r--r-- | library/menu.tcl | 2 | ||||
-rw-r--r-- | library/tk.tcl | 6 | ||||
-rw-r--r-- | library/ttk/button.tcl | 14 | ||||
-rw-r--r-- | library/ttk/combobox.tcl | 24 | ||||
-rw-r--r-- | library/ttk/entry.tcl | 72 | ||||
-rw-r--r-- | library/ttk/menubutton.tcl | 14 | ||||
-rw-r--r-- | library/ttk/notebook.tcl | 28 | ||||
-rw-r--r-- | library/ttk/panedwindow.tcl | 2 | ||||
-rw-r--r-- | library/ttk/scale.tcl | 8 | ||||
-rw-r--r-- | library/ttk/scrollbar.tcl | 14 | ||||
-rw-r--r-- | library/ttk/sizegrip.tcl | 2 | ||||
-rw-r--r-- | library/ttk/spinbox.tcl | 6 | ||||
-rw-r--r-- | library/ttk/treeview.tcl | 28 | ||||
-rw-r--r-- | library/ttk/utils.tcl | 14 | ||||
-rw-r--r-- | tests/constraints.tcl | 8 |
20 files changed, 130 insertions, 130 deletions
diff --git a/library/clrpick.tcl b/library/clrpick.tcl index 600be16..e408d03 100644 --- a/library/clrpick.tcl +++ b/library/clrpick.tcl @@ -396,7 +396,7 @@ proc ::tk::dialog::color::DrawColorScale {w c {create 0}} { # Draw the selection polygons CreateSelector $w $sel $c - $sel bind $data($c,index) <ButtonPress-1> \ + $sel bind $data($c,index) <Button-1> \ [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1] $sel bind $data($c,index) <B1-Motion> \ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)] @@ -409,14 +409,14 @@ proc ::tk::dialog::color::DrawColorScale {w c {create 0}} { set data($c,clickRegion) [$sel create rectangle 0 0 \ $data(canvasWidth) $height -fill {} -outline {}] - bind $col <ButtonPress-1> \ + bind $col <Button-1> \ [list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)] bind $col <B1-Motion> \ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)] bind $col <ButtonRelease-1> \ [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)] - $sel bind $data($c,clickRegion) <ButtonPress-1> \ + $sel bind $data($c,clickRegion) <Button-1> \ [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)] $sel bind $data($c,clickRegion) <B1-Motion> \ [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)] diff --git a/library/console.tcl b/library/console.tcl index 6527607..4e2b9d0 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -131,7 +131,7 @@ proc ::tk::ConsoleInit {} { default { set preferred {} } } foreach {family size} $preferred { - if {[lsearch -exact $families $family] != -1} { + if {$family in $families} { font configure TkConsoleFont -family $family -size $size break } diff --git a/library/demos/knightstour.tcl b/library/demos/knightstour.tcl index 3c29720..b5cffa8 100644 --- a/library/demos/knightstour.tcl +++ b/library/demos/knightstour.tcl @@ -218,7 +218,7 @@ proc CreateGUI {} { -fill black -activefill "#600000" } $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1] - $c bind knight <ButtonPress-1> [namespace code [list DragStart %W %x %y]] + $c bind knight <Button-1> [namespace code [list DragStart %W %x %y]] $c bind knight <Motion> [namespace code [list DragMotion %W %x %y]] $c bind knight <ButtonRelease-1> [namespace code [list DragEnd %W %x %y]] diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 3e2b6df..9197aea 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -121,7 +121,7 @@ proc ::tk::fontchooser::Configure {args} { if {[string trim $S(-title)] eq ""} { set S(-title) [::msgcat::mc "Font"] } - if {[winfo exists $S(W)] && [lsearch $args -font] != -1} { + if {[winfo exists $S(W)] && ("-font" in $args)} { Init $S(-font) event generate $S(-parent) <<TkFontchooserFontChanged>> } diff --git a/library/listbox.tcl b/library/listbox.tcl index a094883..9e628a8 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -311,13 +311,13 @@ proc ::tk::ListboxMotion {w el} { set Priv(listboxSelection) [$w curselection] } while {($i < $el) && ($i < $anchor)} { - if {[lsearch $Priv(listboxSelection) $i] >= 0} { + if {$i in $Priv(listboxSelection)} { $w selection set $i } incr i } while {($i > $el) && ($i > $anchor)} { - if {[lsearch $Priv(listboxSelection) $i] >= 0} { + if {$i in $Priv(listboxSelection)} { $w selection set $i } incr i -1 @@ -517,7 +517,7 @@ proc ::tk::ListboxCancel w { } $w selection clear $first $last while {$first <= $last} { - if {[lsearch $Priv(listboxSelection) $first] >= 0} { + if {$first in $Priv(listboxSelection)} { $w selection set $first } incr first diff --git a/library/menu.tcl b/library/menu.tcl index 9d6370a..c4991f8 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -138,7 +138,7 @@ bind Menu <Leave> { bind Menu <Motion> { tk::MenuMotion %W %x %y %s } -bind Menu <ButtonPress> { +bind Menu <Button> { tk::MenuButtonDown %W } bind Menu <ButtonRelease> { diff --git a/library/tk.tcl b/library/tk.tcl index abe34ab..3657511 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -400,7 +400,7 @@ switch -exact -- [tk windowingsystem] { event add <<NextPara>> <Control-Down> event add <<SelectPrevPara>> <Control-Shift-Up> event add <<SelectNextPara>> <Control-Shift-Down> - event add <<ToggleSelection>> <Control-ButtonPress-1> + event add <<ToggleSelection>> <Control-Button-1> # Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is # returned when the user presses <Shift-Tab>. In order for tab @@ -449,7 +449,7 @@ switch -exact -- [tk windowingsystem] { event add <<NextPara>> <Control-Down> event add <<SelectPrevPara>> <Control-Shift-Up> event add <<SelectNextPara>> <Control-Shift-Down> - event add <<ToggleSelection>> <Control-ButtonPress-1> + event add <<ToggleSelection>> <Control-Button-1> } "aqua" { event add <<Cut>> <Command-Key-x> <Key-F2> <Command-Lock-Key-X> @@ -486,7 +486,7 @@ switch -exact -- [tk windowingsystem] { event add <<NextPara>> <Option-Down> event add <<SelectPrevPara>> <Shift-Option-Up> event add <<SelectNextPara>> <Shift-Option-Down> - event add <<ToggleSelection>> <Command-ButtonPress-1> + event add <<ToggleSelection>> <Command-Button-1> } } diff --git a/library/ttk/button.tcl b/library/ttk/button.tcl index 24065c2..e8c24a1 100644 --- a/library/ttk/button.tcl +++ b/library/ttk/button.tcl @@ -9,7 +9,7 @@ # we get a <Leave> event then, which turns off the "active" state) # # Normally, <ButtonRelease> and <ButtonN-Enter/Leave> events are -# delivered to the widget which received the initial <ButtonPress> +# delivered to the widget which received the initial <Button> # event. However, Tk [grab]s (#1223103) and menu interactions # (#1222605) can interfere with this. To guard against spurious # <Button1-Enter> events, the <Button1-Enter> binding only sets @@ -20,10 +20,10 @@ namespace eval ttk::button {} bind TButton <Enter> { %W instate !disabled {%W state active} } bind TButton <Leave> { %W state !active } -bind TButton <Key-space> { ttk::button::activate %W } +bind TButton <space> { ttk::button::activate %W } bind TButton <<Invoke>> { ttk::button::activate %W } -bind TButton <ButtonPress-1> \ +bind TButton <Button-1> \ { %W instate !disabled { ttk::clickToFocus %W; %W state pressed } } bind TButton <ButtonRelease-1> \ { %W instate pressed { %W state !pressed; %W instate !disabled { %W invoke } } } @@ -39,11 +39,11 @@ ttk::copyBindings TButton TRadiobutton # ...plus a few more: -bind TRadiobutton <KeyPress-Up> { ttk::button::RadioTraverse %W -1 } -bind TRadiobutton <KeyPress-Down> { ttk::button::RadioTraverse %W +1 } +bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 } +bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 } -# bind TCheckbutton <KeyPress-plus> { %W select } -# bind TCheckbutton <KeyPress-minus> { %W deselect } +# bind TCheckbutton <plus> { %W select } +# bind TCheckbutton <minus> { %W deselect } # activate -- # Simulate a button press: temporarily set the state to 'pressed', diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 2378643..e339f97 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -45,13 +45,13 @@ namespace eval ttk::combobox { ttk::copyBindings TEntry TCombobox -bind TCombobox <KeyPress-Down> { ttk::combobox::Post %W } -bind TCombobox <KeyPress-Escape> { ttk::combobox::Unpost %W } +bind TCombobox <Down> { ttk::combobox::Post %W } +bind TCombobox <Escape> { ttk::combobox::Unpost %W } -bind TCombobox <ButtonPress-1> { ttk::combobox::Press "" %W %x %y } -bind TCombobox <Shift-ButtonPress-1> { ttk::combobox::Press "s" %W %x %y } -bind TCombobox <Double-ButtonPress-1> { ttk::combobox::Press "2" %W %x %y } -bind TCombobox <Triple-ButtonPress-1> { ttk::combobox::Press "3" %W %x %y } +bind TCombobox <Button-1> { ttk::combobox::Press "" %W %x %y } +bind TCombobox <Shift-Button-1> { ttk::combobox::Press "s" %W %x %y } +bind TCombobox <Double-Button-1> { ttk::combobox::Press "2" %W %x %y } +bind TCombobox <Triple-Button-1> { ttk::combobox::Press "3" %W %x %y } bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x } bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y } @@ -62,9 +62,9 @@ bind TCombobox <<TraverseIn>> { ttk::combobox::TraverseIn %W } ### Combobox listbox bindings. # bind ComboboxListbox <ButtonRelease-1> { ttk::combobox::LBSelected %W } -bind ComboboxListbox <KeyPress-Return> { ttk::combobox::LBSelected %W } -bind ComboboxListbox <KeyPress-Escape> { ttk::combobox::LBCancel %W } -bind ComboboxListbox <KeyPress-Tab> { ttk::combobox::LBTab %W next } +bind ComboboxListbox <Return> { ttk::combobox::LBSelected %W } +bind ComboboxListbox <Escape> { ttk::combobox::LBCancel %W } +bind ComboboxListbox <Tab> { ttk::combobox::LBTab %W next } bind ComboboxListbox <<PrevWindow>> { ttk::combobox::LBTab %W prev } bind ComboboxListbox <Destroy> { ttk::combobox::LBCleanup %W } bind ComboboxListbox <Motion> { ttk::combobox::LBHover %W %x %y } @@ -82,7 +82,7 @@ switch -- [tk windowingsystem] { # bind ComboboxPopdown <Map> { ttk::combobox::MapPopdown %W } bind ComboboxPopdown <Unmap> { ttk::combobox::UnmapPopdown %W } -bind ComboboxPopdown <ButtonPress> \ +bind ComboboxPopdown <Button> \ { ttk::combobox::Unpost [winfo parent %W] } ### Option database settings. @@ -106,7 +106,7 @@ switch -- [tk windowingsystem] { ### Binding procedures. # -## Press $mode $x $y -- ButtonPress binding for comboboxes. +## Press $mode $x $y -- Button binding for comboboxes. # Either post/unpost the listbox, or perform Entry widget binding, # depending on widget state and location of button press. # @@ -135,7 +135,7 @@ proc ttk::combobox::Press {mode w x y} { } ## Drag -- B1-Motion binding for comboboxes. -# If the initial ButtonPress event was handled by Entry binding, +# If the initial Button event was handled by Entry binding, # perform Entry widget drag binding; otherwise nothing. # proc ttk::combobox::Drag {w x} { diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 1ee6005..4cdb5ac 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -40,20 +40,20 @@ option add *TEntry.cursor [ttk::cursor text] widgetDefault # # Removed the following standard Tk bindings: # -# <Control-Key-space>, <Control-Shift-Key-space>, -# <Key-Select>, <Shift-Key-Select>: +# <Control-space>, <Control-Shift-space>, +# <Select>, <Shift-Select>: # Ttk entry widget doesn't use selection anchor. -# <Key-Insert>: +# <Insert>: # Inserts PRIMARY selection (on non-Windows platforms). # This is inconsistent with typical platform bindings. -# <Double-Shift-ButtonPress-1>, <Triple-Shift-ButtonPress-1>: +# <Double-Shift-Button-1>, <Triple-Shift-Button-1>: # These don't do the right thing to start with. -# <Meta-Key-b>, <Meta-Key-d>, <Meta-Key-f>, -# <Meta-Key-BackSpace>, <Meta-Key-Delete>: +# <Meta-b>, <Meta-d>, <Meta-f>, +# <Meta-BackSpace>, <Meta-Delete>: # Judgment call. If <Meta> happens to be assigned to the Alt key, # these could conflict with application accelerators. # (Plus, who has a Meta key these days?) -# <Control-Key-t>: +# <Control-t>: # Another judgment call. If anyone misses this, let me know # and I'll put it back. # @@ -68,15 +68,15 @@ bind TEntry <<Clear>> { ttk::entry::Clear %W } ## Button1 bindings: # Used for selection and navigation. # -bind TEntry <ButtonPress-1> { ttk::entry::Press %W %x } -bind TEntry <Shift-ButtonPress-1> { ttk::entry::Shift-Press %W %x } -bind TEntry <Double-ButtonPress-1> { ttk::entry::Select %W %x word } -bind TEntry <Triple-ButtonPress-1> { ttk::entry::Select %W %x line } +bind TEntry <Button-1> { ttk::entry::Press %W %x } +bind TEntry <Shift-Button-1> { ttk::entry::Shift-Press %W %x } +bind TEntry <Double-Button-1> { ttk::entry::Select %W %x word } +bind TEntry <Triple-Button-1> { ttk::entry::Select %W %x line } bind TEntry <B1-Motion> { ttk::entry::Drag %W %x } -bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m } -bind TEntry <B1-Enter> { ttk::entry::DragIn %W } -bind TEntry <ButtonRelease-1> { ttk::entry::Release %W } +bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m } +bind TEntry <B1-Enter> { ttk::entry::DragIn %W } +bind TEntry <ButtonRelease-1> { ttk::entry::Release %W } bind TEntry <<ToggleSelection>> { %W instate {!readonly !disabled} { %W icursor @%x ; focus %W } @@ -88,13 +88,13 @@ bind TEntry <<ToggleSelection>> { # is mapped to <<PasteSelection>> in tk.tcl. # if {[tk windowingsystem] ne "aqua"} { - bind TEntry <ButtonPress-2> { ttk::entry::ScanMark %W %x } + bind TEntry <Button-2> { ttk::entry::ScanMark %W %x } bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x } - bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x } + bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x } } else { - bind TEntry <ButtonPress-3> { ttk::entry::ScanMark %W %x } + bind TEntry <Button-3> { ttk::entry::ScanMark %W %x } bind TEntry <B3-Motion> { ttk::entry::ScanDrag %W %x } - bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x } + bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x } } bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x } @@ -121,26 +121,26 @@ bind TEntry <<TraverseIn>> { %W selection range 0 end; %W icursor end } ## Edit bindings: # -bind TEntry <KeyPress> { ttk::entry::Insert %W %A } -bind TEntry <Key-Delete> { ttk::entry::Delete %W } -bind TEntry <Key-BackSpace> { ttk::entry::Backspace %W } +bind TEntry <Key> { ttk::entry::Insert %W %A } +bind TEntry <Delete> { ttk::entry::Delete %W } +bind TEntry <BackSpace> { ttk::entry::Backspace %W } # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. -# Otherwise, the <KeyPress> class binding will fire and insert the character. +# Otherwise, the <Key> class binding will fire and insert the character. # Ditto for Escape, Return, and Tab. # -bind TEntry <Alt-KeyPress> {# nothing} -bind TEntry <Meta-KeyPress> {# nothing} -bind TEntry <Control-KeyPress> {# nothing} -bind TEntry <Key-Escape> {# nothing} -bind TEntry <Key-Return> {# nothing} -bind TEntry <Key-KP_Enter> {# nothing} -bind TEntry <Key-Tab> {# nothing} +bind TEntry <Alt-Key> {# nothing} +bind TEntry <Meta-Key> {# nothing} +bind TEntry <Control-Key> {# nothing} +bind TEntry <Escape> {# nothing} +bind TEntry <Return> {# nothing} +bind TEntry <KP_Enter> {# nothing} +bind TEntry <Tab> {# nothing} # Argh. Apparently on Windows, the NumLock modifier is interpreted # as a Command modifier. if {[tk windowingsystem] eq "aqua"} { - bind TEntry <Command-KeyPress> {# nothing} + bind TEntry <Command-Key> {# nothing} } # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind TEntry <<PrevLine>> {# nothing} @@ -148,9 +148,9 @@ bind TEntry <<NextLine>> {# nothing} ## Additional emacs-like bindings: # -bind TEntry <Control-Key-d> { ttk::entry::Delete %W } -bind TEntry <Control-Key-h> { ttk::entry::Backspace %W } -bind TEntry <Control-Key-k> { %W delete insert end } +bind TEntry <Control-d> { ttk::entry::Delete %W } +bind TEntry <Control-h> { ttk::entry::Backspace %W } +bind TEntry <Control-k> { %W delete insert end } # Bindings for IME text input. @@ -358,7 +358,7 @@ proc ttk::entry::Extend {w where} { # Triple-clicking enters "line-select" mode. # -## Press -- ButtonPress-1 binding. +## Press -- Button-1 binding. # Set the insertion cursor, claim the input focus, set up for # future drag operations. # @@ -375,7 +375,7 @@ proc ttk::entry::Press {w x} { set State(anchor) [$w index insert] } -## Shift-Press -- Shift-ButtonPress-1 binding. +## Shift-Press -- Shift-Button-1 binding. # Extends the selection, sets anchor for future drag operations. # proc ttk::entry::Shift-Press {w x} { @@ -524,7 +524,7 @@ proc ttk::entry::LineSelect {w _ _} { ### Button 2 binding procedures. # -## ScanMark -- ButtonPress-2 binding. +## ScanMark -- Button-2 binding. # Marks the start of a scan or primary transfer operation. # proc ttk::entry::ScanMark {w x} { diff --git a/library/ttk/menubutton.tcl b/library/ttk/menubutton.tcl index bb947c2..a245df8 100644 --- a/library/ttk/menubutton.tcl +++ b/library/ttk/menubutton.tcl @@ -5,7 +5,7 @@ # # Pulldown: Press menubutton, drag over menu, release to activate menu entry # Popdown: Click menubutton to post menu -# Keyboard: <Key-space> or accelerator key to post menu +# Keyboard: <space> or accelerator key to post menu # # (In addition, when menu system is active, "dropdown" -- menu posts # on mouse-over. Ttk menubuttons don't implement this). @@ -19,7 +19,7 @@ # This won't work for Ttk menubuttons in pulldown mode, # since we need to process the final <ButtonRelease> event, # and this might be delivered to the menu. So instead we -# rely on the passive grab that occurs on <ButtonPress> events, +# rely on the passive grab that occurs on <Button> events, # and transition to popdown mode when the mouse is released # or dragged outside the menubutton. # @@ -46,15 +46,15 @@ namespace eval ttk { bind TMenubutton <Enter> { %W instate !disabled {%W state active } } bind TMenubutton <Leave> { %W state !active } -bind TMenubutton <Key-space> { ttk::menubutton::Popdown %W } +bind TMenubutton <space> { ttk::menubutton::Popdown %W } bind TMenubutton <<Invoke>> { ttk::menubutton::Popdown %W } if {[tk windowingsystem] eq "x11"} { - bind TMenubutton <ButtonPress-1> { ttk::menubutton::Pulldown %W } + bind TMenubutton <Button-1> { ttk::menubutton::Pulldown %W } bind TMenubutton <ButtonRelease-1> { ttk::menubutton::TransferGrab %W } bind TMenubutton <B1-Leave> { ttk::menubutton::TransferGrab %W } } else { - bind TMenubutton <ButtonPress-1> \ + bind TMenubutton <Button-1> \ { %W state pressed ; ttk::menubutton::Popdown %W } bind TMenubutton <ButtonRelease-1> \ { if {[winfo exists %W]} { %W state !pressed } } @@ -224,11 +224,11 @@ proc ttk::menubutton::TransferGrab {mb} { # FindMenuEntry -- # Hack to support tk_optionMenus. # Returns the index of the menu entry with a matching -label, -# -1 if not found. +# "" if not found. # proc ttk::menubutton::FindMenuEntry {menu s} { set last [$menu index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return "" } for {set i 0} {$i <= $last} {incr i} { diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl index 92efe40..c5340a5 100644 --- a/library/ttk/notebook.tcl +++ b/library/ttk/notebook.tcl @@ -6,11 +6,11 @@ namespace eval ttk::notebook { variable TLNotebooks ;# See enableTraversal } -bind TNotebook <ButtonPress-1> { ttk::notebook::Press %W %x %y } -bind TNotebook <Key-Right> { ttk::notebook::CycleTab %W 1; break } -bind TNotebook <Key-Left> { ttk::notebook::CycleTab %W -1; break } -bind TNotebook <Control-Key-Tab> { ttk::notebook::CycleTab %W 1; break } -bind TNotebook <Control-Shift-Key-Tab> { ttk::notebook::CycleTab %W -1; break } +bind TNotebook <Button-1> { ttk::notebook::Press %W %x %y } +bind TNotebook <Right> { ttk::notebook::CycleTab %W 1; break } +bind TNotebook <Left> { ttk::notebook::CycleTab %W -1; break } +bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break } +bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break } catch { bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break } } @@ -43,7 +43,7 @@ proc ttk::notebook::ActivateTab {w tab} { } # Press $nb $x $y -- -# ButtonPress-1 binding for notebook widgets. +# Button-1 binding for notebook widgets. # Activate the tab under the mouse cursor, if any. # proc ttk::notebook::Press {w x y} { @@ -105,18 +105,18 @@ proc ttk::notebook::enableTraversal {nb} { if {![info exists TLNotebooks($top)]} { # Augment $top bindings: # - bind $top <Control-Key-Next> {+ttk::notebook::TLCycleTab %W 1} - bind $top <Control-Key-Prior> {+ttk::notebook::TLCycleTab %W -1} - bind $top <Control-Key-Tab> {+ttk::notebook::TLCycleTab %W 1} - bind $top <Control-Shift-Key-Tab> {+ttk::notebook::TLCycleTab %W -1} + bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1} + bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1} + bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1} + bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1} catch { - bind $top <Control-Key-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} + bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} } if {[tk windowingsystem] eq "aqua"} { - bind $top <Option-KeyPress> \ + bind $top <Option-Key> \ +[list ttk::notebook::MnemonicActivation $top %K] } else { - bind $top <Alt-KeyPress> \ + bind $top <Alt-Key> \ +[list ttk::notebook::MnemonicActivation $top %K] } bind $top <Destroy> {+ttk::notebook::TLCleanup %W} @@ -182,7 +182,7 @@ proc ttk::notebook::TLCycleTab {w dir} { } # MnemonicActivation $nb $key -- -# Alt-KeyPress binding procedure for mnemonic activation. +# Alt-Key binding procedure for mnemonic activation. # Scan all notebooks in specified toplevel for a tab with the # the specified mnemonic. If found, activate it and return TCL_BREAK. # diff --git a/library/ttk/panedwindow.tcl b/library/ttk/panedwindow.tcl index ba47003..0fd9bd7 100644 --- a/library/ttk/panedwindow.tcl +++ b/library/ttk/panedwindow.tcl @@ -15,7 +15,7 @@ namespace eval ttk::panedwindow { ## Bindings: # -bind TPanedwindow <ButtonPress-1> { ttk::panedwindow::Press %W %x %y } +bind TPanedwindow <Button-1> { ttk::panedwindow::Press %W %x %y } bind TPanedwindow <B1-Motion> { ttk::panedwindow::Drag %W %x %y } bind TPanedwindow <ButtonRelease-1> { ttk::panedwindow::Release %W %x %y } diff --git a/library/ttk/scale.tcl b/library/ttk/scale.tcl index 62c85bf..61c4136 100644 --- a/library/ttk/scale.tcl +++ b/library/ttk/scale.tcl @@ -9,15 +9,15 @@ namespace eval ttk::scale { } } -bind TScale <ButtonPress-1> { ttk::scale::Press %W %x %y } +bind TScale <Button-1> { ttk::scale::Press %W %x %y } bind TScale <B1-Motion> { ttk::scale::Drag %W %x %y } bind TScale <ButtonRelease-1> { ttk::scale::Release %W %x %y } -bind TScale <ButtonPress-2> { ttk::scale::Jump %W %x %y } +bind TScale <Button-2> { ttk::scale::Jump %W %x %y } bind TScale <B2-Motion> { ttk::scale::Drag %W %x %y } bind TScale <ButtonRelease-2> { ttk::scale::Release %W %x %y } -bind TScale <ButtonPress-3> { ttk::scale::Jump %W %x %y } +bind TScale <Button-3> { ttk::scale::Jump %W %x %y } bind TScale <B3-Motion> { ttk::scale::Drag %W %x %y } bind TScale <ButtonRelease-3> { ttk::scale::Release %W %x %y } @@ -52,7 +52,7 @@ proc ttk::scale::Press {w x y} { } } -# scale::Jump -- ButtonPress-2/3 binding for scale acts like +# scale::Jump -- Button-2/3 binding for scale acts like # Press except that clicking in the trough jumps to the # clicked position. proc ttk::scale::Jump {w x y} { diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl index e939426..1213450 100644 --- a/library/ttk/scrollbar.tcl +++ b/library/ttk/scrollbar.tcl @@ -9,11 +9,11 @@ namespace eval ttk::scrollbar { # State(first) -- value of -first at start of drag. } -bind TScrollbar <ButtonPress-1> { ttk::scrollbar::Press %W %x %y } +bind TScrollbar <Button-1> { ttk::scrollbar::Press %W %x %y } bind TScrollbar <B1-Motion> { ttk::scrollbar::Drag %W %x %y } bind TScrollbar <ButtonRelease-1> { ttk::scrollbar::Release %W %x %y } -bind TScrollbar <ButtonPress-2> { ttk::scrollbar::Jump %W %x %y } +bind TScrollbar <Button-2> { ttk::scrollbar::Jump %W %x %y } bind TScrollbar <B2-Motion> { ttk::scrollbar::Drag %W %x %y } bind TScrollbar <ButtonRelease-2> { ttk::scrollbar::Release %W %x %y } @@ -29,7 +29,7 @@ switch [tk windowingsystem] { x11 { lappend eventList <Button-4> <Button-5> \ <Shift-Button-4> <Shift-Button-5> - # For tk 8.7, the event list should be extended by + # For tk 8.7, the event list will be extended by # <Button-6> <Button-7> } } @@ -59,7 +59,7 @@ proc ttk::scrollbar::Press {w x y} { set State(yPress) $y switch -glob -- [$w identify $x $y] { - *uparrow - + *uparrow - *leftarrow { ttk::Repeatedly Scroll $w -1 units } @@ -67,7 +67,7 @@ proc ttk::scrollbar::Press {w x y} { *rightarrow { ttk::Repeatedly Scroll $w 1 units } - *grip - + *grip - *thumb { set State(first) [lindex [$w get] 0] } @@ -105,7 +105,7 @@ proc ttk::scrollbar::Release {w x y} { ttk::CancelRepeat } -# scrollbar::Jump -- ButtonPress-2 binding for scrollbars. +# scrollbar::Jump -- Button-2 binding for scrollbars. # Behaves exactly like scrollbar::Press, except that # clicking in the trough jumps to the the selected position. # @@ -113,7 +113,7 @@ proc ttk::scrollbar::Jump {w x y} { variable State switch -glob -- [$w identify $x $y] { - *grip - + *grip - *thumb - *trough { set State(first) [$w fraction $x $y] diff --git a/library/ttk/sizegrip.tcl b/library/ttk/sizegrip.tcl index 24a67c6..080ab2d 100644 --- a/library/ttk/sizegrip.tcl +++ b/library/ttk/sizegrip.tcl @@ -32,7 +32,7 @@ namespace eval ttk::sizegrip { } } -bind TSizegrip <ButtonPress-1> { ttk::sizegrip::Press %W %X %Y } +bind TSizegrip <Button-1> { ttk::sizegrip::Press %W %X %Y } bind TSizegrip <B1-Motion> { ttk::sizegrip::Drag %W %X %Y } bind TSizegrip <ButtonRelease-1> { ttk::sizegrip::Release %W %X %Y } diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl index 344ee60..33936d9 100644 --- a/library/ttk/spinbox.tcl +++ b/library/ttk/spinbox.tcl @@ -12,13 +12,13 @@ namespace eval ttk::spinbox { } ttk::copyBindings TEntry TSpinbox bind TSpinbox <Motion> { ttk::spinbox::Motion %W %x %y } -bind TSpinbox <ButtonPress-1> { ttk::spinbox::Press %W %x %y } +bind TSpinbox <Button-1> { ttk::spinbox::Press %W %x %y } bind TSpinbox <ButtonRelease-1> { ttk::spinbox::Release %W } bind TSpinbox <Double-Button-1> { ttk::spinbox::DoubleClick %W %x %y } bind TSpinbox <Triple-Button-1> {} ;# disable TEntry triple-click -bind TSpinbox <KeyPress-Up> { event generate %W <<Increment>> } -bind TSpinbox <KeyPress-Down> { event generate %W <<Decrement>> } +bind TSpinbox <Up> { event generate %W <<Increment>> } +bind TSpinbox <Down> { event generate %W <<Decrement>> } bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 } bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 } diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 1aaae78..62fc630 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -28,20 +28,20 @@ namespace eval ttk::treeview { bind Treeview <Motion> { ttk::treeview::Motion %W %x %y } bind Treeview <B1-Leave> { #nothing } bind Treeview <Leave> { ttk::treeview::ActivateHeading {} {}} -bind Treeview <ButtonPress-1> { ttk::treeview::Press %W %x %y } -bind Treeview <Double-ButtonPress-1> { ttk::treeview::DoubleClick %W %x %y } +bind Treeview <Button-1> { ttk::treeview::Press %W %x %y } +bind Treeview <Double-Button-1> { ttk::treeview::DoubleClick %W %x %y } bind Treeview <ButtonRelease-1> { ttk::treeview::Release %W %x %y } bind Treeview <B1-Motion> { ttk::treeview::Drag %W %x %y } -bind Treeview <KeyPress-Up> { ttk::treeview::Keynav %W up } -bind Treeview <KeyPress-Down> { ttk::treeview::Keynav %W down } -bind Treeview <KeyPress-Right> { ttk::treeview::Keynav %W right } -bind Treeview <KeyPress-Left> { ttk::treeview::Keynav %W left } -bind Treeview <KeyPress-Prior> { %W yview scroll -1 pages } -bind Treeview <KeyPress-Next> { %W yview scroll 1 pages } -bind Treeview <KeyPress-Return> { ttk::treeview::ToggleFocus %W } -bind Treeview <KeyPress-space> { ttk::treeview::ToggleFocus %W } - -bind Treeview <Shift-ButtonPress-1> \ +bind Treeview <Up> { ttk::treeview::Keynav %W up } +bind Treeview <Down> { ttk::treeview::Keynav %W down } +bind Treeview <Right> { ttk::treeview::Keynav %W right } +bind Treeview <Left> { ttk::treeview::Keynav %W left } +bind Treeview <Prior> { %W yview scroll -1 pages } +bind Treeview <Next> { %W yview scroll 1 pages } +bind Treeview <Return> { ttk::treeview::ToggleFocus %W } +bind Treeview <space> { ttk::treeview::ToggleFocus %W } + +bind Treeview <Shift-Button-1> \ { ttk::treeview::Select %W %x %y extend } bind Treeview <<ToggleSelection>> \ { ttk::treeview::Select %W %x %y toggle } @@ -155,7 +155,7 @@ proc ttk::treeview::Select {w x y op} { } } -## DoubleClick -- Double-ButtonPress-1 binding. +## DoubleClick -- Double-Button-1 binding. # proc ttk::treeview::DoubleClick {w x y} { if {[set row [$w identify row $x $y]] ne ""} { @@ -165,7 +165,7 @@ proc ttk::treeview::DoubleClick {w x y} { } } -## Press -- ButtonPress binding. +## Press -- Button binding. # proc ttk::treeview::Press {w x y} { focus $w diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl index 101162f..7a5cc71 100644 --- a/library/ttk/utils.tcl +++ b/library/ttk/utils.tcl @@ -58,7 +58,7 @@ proc ttk::traverseTo {w} { } ## ttk::clickToFocus $w -- -# Utility routine, used in <ButtonPress-1> bindings -- +# Utility routine, used in <Button-1> bindings -- # Assign keyboard focus to the specified widget if -takefocus is enabled. # proc ttk::clickToFocus {w} { @@ -298,8 +298,8 @@ proc ttk::copyBindings {from to} { proc ttk::bindMouseWheel {bindtag callback} { if {[tk windowingsystem] eq "x11"} { - bind $bindtag <ButtonPress-4> "$callback -1" - bind $bindtag <ButtonPress-5> "$callback +1" + bind $bindtag <Button-4> "$callback -1" + bind $bindtag <Button-5> "$callback +1" } if {[tk windowingsystem] eq "aqua"} { bind $bindtag <MouseWheel> [append callback { [expr {-(%D)}]} ] @@ -318,10 +318,10 @@ proc ttk::bindMouseWheel {bindtag callback} { # if {[tk windowingsystem] eq "x11"} { - bind TtkScrollable <ButtonPress-4> { %W yview scroll -5 units } - bind TtkScrollable <ButtonPress-5> { %W yview scroll 5 units } - bind TtkScrollable <Shift-ButtonPress-4> { %W xview scroll -5 units } - bind TtkScrollable <Shift-ButtonPress-5> { %W xview scroll 5 units } + bind TtkScrollable <Button-4> { %W yview scroll -5 units } + bind TtkScrollable <Button-5> { %W yview scroll 5 units } + bind TtkScrollable <Shift-Button-4> { %W xview scroll -5 units } + bind TtkScrollable <Shift-Button-5> { %W xview scroll 5 units } } if {[tk windowingsystem] eq "aqua"} { bind TtkScrollable <MouseWheel> \ diff --git a/tests/constraints.tcl b/tests/constraints.tcl index ff036f3..9b48e8d 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -197,8 +197,8 @@ testConstraint noExceed [expr { }] # constraints for testing facilities defined in the tktest executable... -testConstraint testImageType [expr {[lsearch [image types] test] >= 0}] -testConstraint testOldImageType [expr {[lsearch [image types] oldtest] >= 0}] +testConstraint testImageType [expr {"test" in [image types]}] +testConstraint testOldImageType [expr {"oldtest" in [image types]}] testConstraint testbitmap [llength [info commands testbitmap]] testConstraint testborder [llength [info commands testborder]] testConstraint testcbind [llength [info commands testcbind]] @@ -247,10 +247,10 @@ testConstraint pseudocolor8 [expr { }] destroy .t testConstraint haveTruecolor24 [expr { - [lsearch -exact [winfo visualsavailable .] {truecolor 24}] >= 0 + {truecolor 24} in [winfo visualsavailable .] }] testConstraint haveGrayscale8 [expr { - [lsearch -exact [winfo visualsavailable .] {grayscale 8}] >= 0 + {grayscale 8} in [winfo visualsavailable .] }] testConstraint defaultPseudocolor8 [expr { ([winfo visual .] eq "pseudocolor") && ([winfo depth .] == 8) |