summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-01-06 18:37:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-01-06 18:37:35 (GMT)
commit078fd483b608ea19f2d47f36f5a6a8a3a1c04405 (patch)
treeeb752269f6622bc209b2f65910151a86a2369d2a /library
parent1a6ac30b077e52ba1da9ac22a8d38356ece00cec (diff)
downloadtk-078fd483b608ea19f2d47f36f5a6a8a3a1c04405.zip
tk-078fd483b608ea19f2d47f36f5a6a8a3a1c04405.tar.gz
tk-078fd483b608ea19f2d47f36f5a6a8a3a1c04405.tar.bz2
Centralize the definitions of what keys do particular types of left and right
movements in entries and text widgets. They vary between platforms!
Diffstat (limited to 'library')
-rw-r--r--library/entry.tcl28
-rw-r--r--library/spinbox.tcl28
-rw-r--r--library/text.tcl26
-rw-r--r--library/tk.tcl45
-rw-r--r--library/ttk/entry.tcl28
5 files changed, 101 insertions, 54 deletions
diff --git a/library/entry.tcl b/library/entry.tcl
index 9d93a24..b92f8b9 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk entry widgets and provides
# procedures that help in implementing those bindings.
#
-# RCS: @(#) $Id: entry.tcl,v 1.26 2007/12/13 15:26:27 dgp Exp $
+# RCS: @(#) $Id: entry.tcl,v 1.27 2010/01/06 18:37:36 dkf Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -121,45 +121,45 @@ bind Entry <Control-1> {
%W icursor @%x
}
-bind Entry <Left> {
+bind Entry <<PrevChar>> {
tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
}
-bind Entry <Right> {
+bind Entry <<NextChar>> {
tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
}
-bind Entry <Shift-Left> {
+bind Entry <<SelectPrevChar>> {
tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
tk::EntrySeeInsert %W
}
-bind Entry <Shift-Right> {
+bind Entry <<SelectNextChar>> {
tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
tk::EntrySeeInsert %W
}
-bind Entry <Control-Left> {
+bind Entry <<PrevWord>> {
tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert]
}
-bind Entry <Control-Right> {
+bind Entry <<NextWord>> {
tk::EntrySetCursor %W [tk::EntryNextWord %W insert]
}
-bind Entry <Shift-Control-Left> {
+bind Entry <<SelectPrevWord>> {
tk::EntryKeySelect %W [tk::EntryPreviousWord %W insert]
tk::EntrySeeInsert %W
}
-bind Entry <Shift-Control-Right> {
+bind Entry <<SelectNextWord>> {
tk::EntryKeySelect %W [tk::EntryNextWord %W insert]
tk::EntrySeeInsert %W
}
-bind Entry <Home> {
+bind Entry <<LineStart>> {
tk::EntrySetCursor %W 0
}
-bind Entry <Shift-Home> {
+bind Entry <<SelectLineStart>> {
tk::EntryKeySelect %W 0
tk::EntrySeeInsert %W
}
-bind Entry <End> {
+bind Entry <<LineEnd>> {
tk::EntrySetCursor %W end
}
-bind Entry <Shift-End> {
+bind Entry <<SelectLineEnd>> {
tk::EntryKeySelect %W end
tk::EntrySeeInsert %W
}
@@ -210,6 +210,8 @@ bind Entry <Escape> {# nothing}
bind Entry <Return> {# nothing}
bind Entry <KP_Enter> {# nothing}
bind Entry <Tab> {# nothing}
+bind Entry <Prior> {# nothing}
+bind Entry <Next> {# nothing}
if {[tk windowingsystem] eq "aqua"} {
bind Entry <Command-KeyPress> {# nothing}
}
diff --git a/library/spinbox.tcl b/library/spinbox.tcl
index f470888..4df106f 100644
--- a/library/spinbox.tcl
+++ b/library/spinbox.tcl
@@ -4,7 +4,7 @@
# procedures that help in implementing those bindings. The spinbox builds
# off the entry widget, so it can reuse Entry bindings and procedures.
#
-# RCS: @(#) $Id: spinbox.tcl,v 1.9 2005/07/25 09:06:00 dkf Exp $
+# RCS: @(#) $Id: spinbox.tcl,v 1.10 2010/01/06 18:37:36 dkf Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -129,45 +129,45 @@ bind Spinbox <Down> {
%W invoke buttondown
}
-bind Spinbox <Left> {
+bind Spinbox <<PrevChar>> {
::tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
}
-bind Spinbox <Right> {
+bind Spinbox <<NextChar>> {
::tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
}
-bind Spinbox <Shift-Left> {
+bind Spinbox <<SelectPrevChar>> {
::tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
::tk::EntrySeeInsert %W
}
-bind Spinbox <Shift-Right> {
+bind Spinbox <<SelectNextChar>> {
::tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
::tk::EntrySeeInsert %W
}
-bind Spinbox <Control-Left> {
+bind Spinbox <<PrevWord>> {
::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert]
}
-bind Spinbox <Control-Right> {
+bind Spinbox <<NextWord>> {
::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert]
}
-bind Spinbox <Shift-Control-Left> {
+bind Spinbox <<SelectPrevWord>> {
::tk::EntryKeySelect %W [::tk::EntryPreviousWord %W insert]
::tk::EntrySeeInsert %W
}
-bind Spinbox <Shift-Control-Right> {
+bind Spinbox <<SelectNextWord>> {
::tk::EntryKeySelect %W [::tk::EntryNextWord %W insert]
::tk::EntrySeeInsert %W
}
-bind Spinbox <Home> {
+bind Spinbox <<LineStart>> {
::tk::EntrySetCursor %W 0
}
-bind Spinbox <Shift-Home> {
+bind Spinbox <<SelectLineStart>> {
::tk::EntryKeySelect %W 0
::tk::EntrySeeInsert %W
}
-bind Spinbox <End> {
+bind Spinbox <<LineEnd>> {
::tk::EntrySetCursor %W end
}
-bind Spinbox <Shift-End> {
+bind Spinbox <<SelectLineEnd>> {
::tk::EntryKeySelect %W end
::tk::EntrySeeInsert %W
}
@@ -217,6 +217,8 @@ bind Spinbox <Escape> {# nothing}
bind Spinbox <Return> {# nothing}
bind Spinbox <KP_Enter> {# nothing}
bind Spinbox <Tab> {# nothing}
+bind Spinbox <Prior> {# nothing}
+bind Spinbox <Next> {# nothing}
if {[tk windowingsystem] eq "aqua"} {
bind Spinbox <Command-KeyPress> {# nothing}
}
diff --git a/library/text.tcl b/library/text.tcl
index 509d425..74a8d6b 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk text widgets and provides
# procedures that help in implementing the bindings.
#
-# RCS: @(#) $Id: text.tcl,v 1.44 2009/10/25 13:47:16 dkf Exp $
+# RCS: @(#) $Id: text.tcl,v 1.45 2010/01/06 18:37:36 dkf Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -88,10 +88,10 @@ bind Text <ButtonRelease-1> {
bind Text <Control-1> {
%W mark set insert @%x,%y
}
-bind Text <Left> {
+bind Text <<PrevChar>> {
tk::TextSetCursor %W insert-1displayindices
}
-bind Text <Right> {
+bind Text <<NextChar>> {
tk::TextSetCursor %W insert+1displayindices
}
bind Text <Up> {
@@ -100,10 +100,10 @@ bind Text <Up> {
bind Text <Down> {
tk::TextSetCursor %W [tk::TextUpDownLine %W 1]
}
-bind Text <Shift-Left> {
+bind Text <<SelectPrevChar>> {
tk::TextKeySelect %W [%W index {insert - 1displayindices}]
}
-bind Text <Shift-Right> {
+bind Text <<SelectNextChar>> {
tk::TextKeySelect %W [%W index {insert + 1displayindices}]
}
bind Text <Shift-Up> {
@@ -112,10 +112,10 @@ bind Text <Shift-Up> {
bind Text <Shift-Down> {
tk::TextKeySelect %W [tk::TextUpDownLine %W 1]
}
-bind Text <Control-Left> {
+bind Text <<PrevWord>> {
tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
}
-bind Text <Control-Right> {
+bind Text <<NextWord>> {
tk::TextSetCursor %W [tk::TextNextWord %W insert]
}
bind Text <Control-Up> {
@@ -124,10 +124,10 @@ bind Text <Control-Up> {
bind Text <Control-Down> {
tk::TextSetCursor %W [tk::TextNextPara %W insert]
}
-bind Text <Shift-Control-Left> {
+bind Text <<SelectPrevWord>> {
tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
}
-bind Text <Shift-Control-Right> {
+bind Text <<SelectNextWord>> {
tk::TextKeySelect %W [tk::TextNextWord %W insert]
}
bind Text <Shift-Control-Up> {
@@ -155,16 +155,16 @@ bind Text <Control-Next> {
%W xview scroll 1 page
}
-bind Text <Home> {
+bind Text <<LineStart>> {
tk::TextSetCursor %W {insert display linestart}
}
-bind Text <Shift-Home> {
+bind Text <<SelectLineStart>> {
tk::TextKeySelect %W {insert display linestart}
}
-bind Text <End> {
+bind Text <<LineEnd>> {
tk::TextSetCursor %W {insert display lineend}
}
-bind Text <Shift-End> {
+bind Text <<SelectLineEnd>> {
tk::TextKeySelect %W {insert display lineend}
}
bind Text <Control-Home> {
diff --git a/library/tk.tcl b/library/tk.tcl
index d80feb0..c73d110 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -3,7 +3,7 @@
# Initialization script normally executed in the interpreter for each Tk-based
# application. Arranges class bindings for widgets.
#
-# RCS: @(#) $Id: tk.tcl,v 1.89 2010/01/04 01:36:14 patthoyts Exp $
+# RCS: @(#) $Id: tk.tcl,v 1.90 2010/01/06 18:37:37 dkf Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -374,6 +374,19 @@ switch -exact -- [tk windowingsystem] {
event add <<ContextMenu>> <Button-2>
}
+ event add <<NextChar>> <Right>
+ event add <<SelectNextChar>> <Shift-Right>
+ event add <<PrevChar>> <Left>
+ event add <<SelectPrevChar>> <Shift-Left>
+ event add <<NextWord>> <Control-Right>
+ event add <<SelectNextWord>> <Shift-Control-Right>
+ event add <<PrevWord>> <Control-Left>
+ event add <<SelectPrevWord>> <Shift-Control-Left>
+ event add <<LineStart>> <Home>
+ event add <<SelectLineStart>> <Shift-Home>
+ event add <<LineEnd>> <End>
+ event add <<SelectLineEnd>> <Shift-End>
+
# 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
# traversal to work, we have to add these keysyms to the PrevWindow
@@ -401,6 +414,19 @@ switch -exact -- [tk windowingsystem] {
event add <<Undo>> <Control-Key-z> <Control-Lock-Key-Z>
event add <<Redo>> <Control-Key-y> <Control-Lock-Key-Y>
event add <<ContextMenu>> <Button-3>
+
+ event add <<NextChar>> <Right>
+ event add <<SelectNextChar>> <Shift-Right>
+ event add <<PrevChar>> <Left>
+ event add <<SelectPrevChar>> <Shift-Left>
+ event add <<NextWord>> <Control-Right>
+ event add <<SelectNextWord>> <Shift-Control-Right>
+ event add <<PrevWord>> <Control-Left>
+ event add <<SelectPrevWord>> <Shift-Control-Left>
+ event add <<LineStart>> <Home>
+ event add <<SelectLineStart>> <Shift-Home>
+ event add <<LineEnd>> <End>
+ event add <<SelectLineEnd>> <Shift-End>
}
"aqua" {
event add <<Cut>> <Command-Key-x> <Key-F2> <Control-Lock-Key-X>
@@ -411,6 +437,23 @@ switch -exact -- [tk windowingsystem] {
event add <<Undo>> <Command-Key-z> <Control-Lock-Key-Z>
event add <<Redo>> <Command-Key-y> <Control-Lock-Key-Y>
event add <<ContextMenu>> <Button-2>
+
+ # Official bindings
+ # See http://support.apple.com/kb/HT1343
+ event add <<NextChar>> <Right>
+ event add <<SelectNextChar>> <Shift-Right>
+ event add <<PrevChar>> <Left>
+ event add <<SelectPrevChar>> <Shift-Left>
+ event add <<NextWord>> <Option-Right>
+ event add <<SelectNextWord>> <Shift-Option-Right>
+ event add <<PrevWord>> <Option-Left>
+ event add <<SelectPrevWord>> <Shift-Option-Left>
+ event add <<SelectLineStart>> <Shift-Home> <Shift-Command-Left>
+ event add <<SelectLineEnd>> <Shift-End> <Shift-Command-Right>
+ # Not official, but logical extensions of above. Also derived from
+ # bindings present in MS Word on OSX.
+ event add <<LineStart>> <Home> <Command-Left>
+ event add <<LineEnd>> <End> <Command-Right>
}
}
diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl
index d54328a..a3a81a3 100644
--- a/library/ttk/entry.tcl
+++ b/library/ttk/entry.tcl
@@ -1,5 +1,5 @@
#
-# $Id: entry.tcl,v 1.6 2008/11/01 15:34:24 patthoyts Exp $
+# $Id: entry.tcl,v 1.7 2010/01/06 18:37:37 dkf Exp $
#
# DERIVED FROM: tk/library/entry.tcl r1.22
#
@@ -95,19 +95,19 @@ bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x }
## Keyboard navigation bindings:
#
-bind TEntry <Key-Left> { ttk::entry::Move %W prevchar }
-bind TEntry <Key-Right> { ttk::entry::Move %W nextchar }
-bind TEntry <Control-Key-Left> { ttk::entry::Move %W prevword }
-bind TEntry <Control-Key-Right> { ttk::entry::Move %W nextword }
-bind TEntry <Key-Home> { ttk::entry::Move %W home }
-bind TEntry <Key-End> { ttk::entry::Move %W end }
-
-bind TEntry <Shift-Key-Left> { ttk::entry::Extend %W prevchar }
-bind TEntry <Shift-Key-Right> { ttk::entry::Extend %W nextchar }
-bind TEntry <Shift-Control-Key-Left> { ttk::entry::Extend %W prevword }
-bind TEntry <Shift-Control-Key-Right> { ttk::entry::Extend %W nextword }
-bind TEntry <Shift-Key-Home> { ttk::entry::Extend %W home }
-bind TEntry <Shift-Key-End> { ttk::entry::Extend %W end }
+bind TEntry <<PrevChar>> { ttk::entry::Move %W prevchar }
+bind TEntry <<NextChar>> { ttk::entry::Move %W nextchar }
+bind TEntry <<PrevWord>> { ttk::entry::Move %W prevword }
+bind TEntry <<NextWord>> { ttk::entry::Move %W nextword }
+bind TEntry <<LineStart>> { ttk::entry::Move %W home }
+bind TEntry <<LineEnd>> { ttk::entry::Move %W end }
+
+bind TEntry <<SelectPrevChar>> { ttk::entry::Extend %W prevchar }
+bind TEntry <<SelectNextChar>> { ttk::entry::Extend %W nextchar }
+bind TEntry <<SelectPrevWord>> { ttk::entry::Extend %W prevword }
+bind TEntry <<SelectNextWord>> { ttk::entry::Extend %W nextword }
+bind TEntry <<SelectLineStart>> { ttk::entry::Extend %W home }
+bind TEntry <<SelectLineEnd>> { ttk::entry::Extend %W end }
bind TEntry <Control-Key-slash> { %W selection range 0 end }
bind TEntry <Control-Key-backslash> { %W selection clear }