summaryrefslogtreecommitdiffstats
path: root/library/ttk/notebook.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs>2010-08-26 02:06:08 (GMT)
committerhobbs <hobbs>2010-08-26 02:06:08 (GMT)
commitb29adcfbfc2e03e058536524f1aa3378b948e7ed (patch)
treefa90e1e6d32590addfbb0a1599a40b1f7f99ea3b /library/ttk/notebook.tcl
parent7dec1714e5d5efd6b7d095657c1434fa68af0f87 (diff)
downloadtk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.zip
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.gz
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.bz2
Major backport of 8.6 Ttk for 8.5.9. Most changes were only being
committed to head (8.6), although they could apply for 8.5 as well. This re-sync makes future work easier to maintain and adds some useful work for 8.5 users. Notable changes: - Lots of code cleanup - Some bug fixes never backported - Addition of ttk::spinbox - minor color changes - Improved Vista/7 styling - Move to tile version 0.8.6 (pseudo-package) - ABI and API compatible (even $w identify) - minor new features (extended $w identify)
Diffstat (limited to 'library/ttk/notebook.tcl')
-rw-r--r--library/ttk/notebook.tcl33
1 files changed, 20 insertions, 13 deletions
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index 4fe58cc..cf5ffc1 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -1,5 +1,5 @@
#
-# $Id: notebook.tcl,v 1.4 2007/02/24 09:15:07 das Exp $
+# $Id: notebook.tcl,v 1.4.4.1 2010/08/26 02:06:10 hobbs Exp $
#
# Bindings for TNotebook widget
#
@@ -21,21 +21,26 @@ bind TNotebook <Destroy> { ttk::notebook::Cleanup %W }
# ActivateTab $nb $tab --
# Select the specified tab and set focus.
#
-# If $tab was already the current tab, set the focus to the
-# notebook widget. Otherwise, set the focus to the first
-# traversable widget in the pane. The behavior is that the
-# notebook takes focus when the user selects the same tab
-# a second time. This mirrors Windows tab behavior.
+# Desired behavior:
+# + take focus when reselecting the currently-selected tab;
+# + keep focus if the notebook already has it;
+# + otherwise set focus to the first traversable widget
+# in the newly-selected tab;
+# + do not leave the focus in a deselected tab.
#
proc ttk::notebook::ActivateTab {w tab} {
- if {[$w index $tab] eq [$w index current]} {
- focus $w
+ set oldtab [$w select]
+ $w select $tab
+ set newtab [$w select] ;# NOTE: might not be $tab, if $tab is disabled
+
+ if {[focus] eq $w} { return }
+ if {$newtab eq $oldtab} { focus $w ; return }
+
+ update idletasks ;# needed so focus logic sees correct mapped states
+ if {[set f [ttk::focusFirst $newtab]] ne ""} {
+ ttk::traverseTo $f
} else {
- $w select $tab
- update ;# needed so focus logic sees correct mapped/unmapped states
- if {[set f [ttk::focusFirst [$w select]]] ne ""} {
- tk::TabToWindow $f
- }
+ focus $w
}
}
@@ -102,6 +107,8 @@ 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 <Shift-Control-Key-Tab> {+ttk::notebook::TLCycleTab %W -1}
catch {