From ebe99473e61961e6e6c4525ed9efe66f7c3de308 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 9 Aug 2012 11:03:00 +0000 Subject: [Bug 3555644]: Better use of virtual events. --- ChangeLog | 4 ++++ library/console.tcl | 6 ++---- library/demos/entry3.tcl | 4 ++-- library/entry.tcl | 10 ---------- library/iconlist.tcl | 4 ++-- library/listbox.tcl | 12 ++++++------ library/menu.tcl | 4 ++-- library/scale.tcl | 12 ++++++------ library/scrlbar.tcl | 12 ++++++------ library/spinbox.tcl | 10 ---------- library/text.tcl | 24 +----------------------- library/tk.tcl | 12 ++++++------ library/ttk/entry.tcl | 2 -- library/ttk/scale.tcl | 15 +++++++++------ 14 files changed, 46 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a98897..3b3e1aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-08-?? Jan Nijtmans + + * library/*.tcl: [Bug 3555644]: Better use of virtual events. + 2012-07-31 Donal K. Fellows * unix/tkUnixKey.c (TkpSetKeycodeAndState, TkpInitKeymapInfo) diff --git a/library/console.tcl b/library/console.tcl index e6b7ce9..37832f2 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -499,18 +499,16 @@ proc ::tk::ConsoleBind {w} { } bind Console [bind Console ] - bind Console { + bind Console <> { if {[%W compare insert < promptEnd]} { tk::TextSetCursor %W {insert linestart} } else { tk::TextSetCursor %W promptEnd } } - bind Console [bind Console ] - bind Console { + bind Console <> { tk::TextSetCursor %W {insert lineend} } - bind Console [bind Console ] bind Console { if {[%W compare insert < promptEnd]} { break diff --git a/library/demos/entry3.tcl b/library/demos/entry3.tcl index 3d76c2e..d4435c6 100644 --- a/library/demos/entry3.tcl +++ b/library/demos/entry3.tcl @@ -169,8 +169,8 @@ bind $w.l3.e { after idle {%W selection clear} } } -bind $w.l3.e {phoneSkipLeft %W} -bind $w.l3.e {phoneSkipRight %W} +bind $w.l3.e <> {phoneSkipLeft %W} +bind $w.l3.e <> {phoneSkipRight %W} pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m labelframe $w.l4 -text "Password Entry" diff --git a/library/entry.tcl b/library/entry.tcl index de6c463..5dbf063 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -227,11 +227,6 @@ if {[tk windowingsystem] ne "win32"} { # Additional emacs-like bindings: -bind Entry { - if {!$tk_strictMotif} { - tk::EntrySetCursor %W 0 - } -} bind Entry { if {!$tk_strictMotif} { tk::EntrySetCursor %W [expr {[%W index insert] - 1}] @@ -242,11 +237,6 @@ bind Entry { %W delete insert } } -bind Entry { - if {!$tk_strictMotif} { - tk::EntrySetCursor %W end - } -} bind Entry { if {!$tk_strictMotif} { tk::EntrySetCursor %W [expr {[%W index insert] + 1}] diff --git a/library/iconlist.tcl b/library/iconlist.tcl index fc8128d..15a4f53 100644 --- a/library/iconlist.tcl +++ b/library/iconlist.tcl @@ -446,8 +446,8 @@ package require Tk 8.6 bind $canvas [namespace code {my UpDown -1}] bind $canvas [namespace code {my UpDown 1}] - bind $canvas [namespace code {my LeftRight -1}] - bind $canvas [namespace code {my LeftRight 1}] + bind $canvas <> [namespace code {my LeftRight -1}] + bind $canvas <> [namespace code {my LeftRight 1}] bind $canvas [namespace code {my ReturnKey}] bind $canvas [namespace code {my KeyPress %A}] bind $canvas ";" diff --git a/library/listbox.tcl b/library/listbox.tcl index 99047f4..eae513a 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -81,16 +81,16 @@ bind Listbox { bind Listbox { tk::ListboxExtendUpDown %W 1 } -bind Listbox { +bind Listbox <> { %W xview scroll -1 units } -bind Listbox { +bind Listbox <> { %W xview scroll -1 pages } -bind Listbox { +bind Listbox <> { %W xview scroll 1 units } -bind Listbox { +bind Listbox <> { %W xview scroll 1 pages } bind Listbox { @@ -107,10 +107,10 @@ bind Listbox { bind Listbox { %W xview scroll 1 pages } -bind Listbox { +bind Listbox <> { %W xview moveto 0 } -bind Listbox { +bind Listbox <> { %W xview moveto 1 } bind Listbox { diff --git a/library/menu.tcl b/library/menu.tcl index cc57532..8261e82 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -149,10 +149,10 @@ bind Menu { bind Menu { tk::MenuEscape %W } -bind Menu { +bind Menu <> { tk::MenuLeftArrow %W } -bind Menu { +bind Menu <> { tk::MenuRightArrow %W } bind Menu { diff --git a/library/scale.tcl b/library/scale.tcl index b4da824..72a254a 100644 --- a/library/scale.tcl +++ b/library/scale.tcl @@ -77,10 +77,10 @@ bind Scale { bind Scale { tk::ScaleIncrement %W down little noRepeat } -bind Scale { +bind Scale <> { tk::ScaleIncrement %W up little noRepeat } -bind Scale { +bind Scale <> { tk::ScaleIncrement %W down little noRepeat } bind Scale { @@ -89,16 +89,16 @@ bind Scale { bind Scale { tk::ScaleIncrement %W down big noRepeat } -bind Scale { +bind Scale <> { tk::ScaleIncrement %W up big noRepeat } -bind Scale { +bind Scale <> { tk::ScaleIncrement %W down big noRepeat } -bind Scale { +bind Scale <> { %W set [%W cget -from] } -bind Scale { +bind Scale <> { %W set [%W cget -to] } diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 9277160..4a16f0b 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -103,16 +103,16 @@ bind Scrollbar { bind Scrollbar { tk::ScrollByPages %W v 1 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollByUnits %W h -1 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollByUnits %W h 1 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollByPages %W h -1 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollByPages %W h 1 } bind Scrollbar { @@ -121,10 +121,10 @@ bind Scrollbar { bind Scrollbar { tk::ScrollByPages %W hv 1 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollToPos %W 0 } -bind Scrollbar { +bind Scrollbar <> { tk::ScrollToPos %W 1 } } diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 20b477a..d5b4d79 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -231,11 +231,6 @@ if {[tk windowingsystem] ne "win32"} { # Additional emacs-like bindings: -bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W 0 - } -} bind Spinbox { if {!$tk_strictMotif} { ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] @@ -246,11 +241,6 @@ bind Spinbox { %W delete insert } } -bind Spinbox { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W end - } -} bind Spinbox { if {!$tk_strictMotif} { ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] diff --git a/library/text.tcl b/library/text.tcl index 331d1b4..a71150a 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -287,11 +287,6 @@ if {[tk windowingsystem] eq "aqua"} { # Additional emacs-like bindings: -bind Text { - if {!$tk_strictMotif} { - tk::TextSetCursor %W {insert display linestart} - } -} bind Text { if {!$tk_strictMotif} { tk::TextSetCursor %W insert-1displayindices @@ -302,11 +297,6 @@ bind Text { %W delete insert } } -bind Text { - if {!$tk_strictMotif} { - tk::TextSetCursor %W {insert display lineend} - } -} bind Text { if {!$tk_strictMotif} { tk::TextSetCursor %W insert+1displayindices @@ -390,31 +380,19 @@ bind Text { # Macintosh only bindings: if {[tk windowingsystem] eq "aqua"} { -bind Text { - tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] -} -bind Text { - tk::TextSetCursor %W [tk::TextNextWord %W insert] -} bind Text { tk::TextSetCursor %W [tk::TextPrevPara %W insert] } bind Text { tk::TextSetCursor %W [tk::TextNextPara %W insert] } -bind Text { - tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] -} -bind Text { - tk::TextKeySelect %W [tk::TextNextWord %W insert] -} bind Text { tk::TextKeySelect %W [tk::TextPrevPara %W insert] } bind Text { tk::TextKeySelect %W [tk::TextNextPara %W insert] } -bind Text { +bind Text <> { tk::TextScrollPages %W 1 } diff --git a/library/tk.tcl b/library/tk.tcl index 928fc2e..33671ed 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -377,9 +377,9 @@ switch -exact -- [tk windowingsystem] { event add <> event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> event add <> # Some OS's define a goofy (as in, not ) keysym that is @@ -418,9 +418,9 @@ switch -exact -- [tk windowingsystem] { event add <> event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> event add <> } "aqua" { @@ -447,8 +447,8 @@ switch -exact -- [tk windowingsystem] { event add <> # Not official, but logical extensions of above. Also derived from # bindings present in MS Word on OSX. - event add <> - event add <> + event add <> + event add <> } } diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index a27921a..9e0d6e1 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -141,10 +141,8 @@ bind TEntry {# nothing} ## Additional emacs-like bindings: # -bind TEntry { ttk::entry::Move %W home } bind TEntry { ttk::entry::Move %W prevchar } bind TEntry { ttk::entry::Delete %W } -bind TEntry { ttk::entry::Move %W end } bind TEntry { ttk::entry::Move %W nextchar } bind TEntry { ttk::entry::Backspace %W } bind TEntry { %W delete insert end } diff --git a/library/ttk/scale.tcl b/library/ttk/scale.tcl index 23d08ed..f270697 100644 --- a/library/ttk/scale.tcl +++ b/library/ttk/scale.tcl @@ -21,16 +21,19 @@ bind TScale { ttk::scale::Jump %W %x %y } bind TScale { ttk::scale::Drag %W %x %y } bind TScale { ttk::scale::Release %W %x %y } -bind TScale { ttk::scale::Increment %W -1 } +## Keyboard navigation bindings: +# +bind TScale <> { %W set [%W cget -from] } +bind TScale <> { %W set [%W cget -to] } + +bind TScale <> { ttk::scale::Increment %W -1 } bind TScale { ttk::scale::Increment %W -1 } -bind TScale { ttk::scale::Increment %W 1 } +bind TScale <> { ttk::scale::Increment %W 1 } bind TScale { ttk::scale::Increment %W 1 } -bind TScale { ttk::scale::Increment %W -10 } +bind TScale <> { ttk::scale::Increment %W -10 } bind TScale { ttk::scale::Increment %W -10 } -bind TScale { ttk::scale::Increment %W 10 } +bind TScale <> { ttk::scale::Increment %W 10 } bind TScale { ttk::scale::Increment %W 10 } -bind TScale { %W set [%W cget -from] } -bind TScale { %W set [%W cget -to] } proc ttk::scale::Press {w x y} { variable State -- cgit v0.12