From 54336c5070ceca45adeebef398a457aa99dd5f63 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 28 Dec 2008 23:43:14 +0000 Subject: Corrected mouse-wheel bindings for widgets. Now Shift-wheel always scrolls the text widget horizontally on all platforms. --- ChangeLog | 3 +++ library/listbox.tcl | 15 ++++++++++++++- library/scrlbar.tcl | 38 +++++++++++++++++++++++++++----------- library/text.tcl | 19 ++++++++++++++++++- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67c6f3f..900b293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ TIP #171 IMPLEMENTATION + * library/listbox.tcl, library/scrlbar.tcl, library/text.tcl: Adjust + users of the event to do the right thing horizontally as + well as vertically. * win/tkWinX.c (GenerateXEvent): Redirect to the window that contains the mouse. * generic/tkEvent.c (InvokeFocusHandlers): Do not direct diff --git a/library/listbox.tcl b/library/listbox.tcl index a746b8a..80310a5 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk listbox widgets # and provides procedures that help in implementing those bindings. # -# RCS: @(#) $Id: listbox.tcl,v 1.18 2007/12/13 15:26:27 dgp Exp $ +# RCS: @(#) $Id: listbox.tcl,v 1.19 2008/12/28 23:43:14 dkf Exp $ # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994-1995 Sun Microsystems, Inc. @@ -196,6 +196,9 @@ if {[tk windowingsystem] eq "aqua"} { bind Listbox { %W yview scroll [expr {- (%D / 120) * 4}] units } + bind Listbox { + %W xview scroll [expr {- (%D / 120) * 4}] units + } } if {"x11" eq [tk windowingsystem]} { @@ -208,11 +211,21 @@ if {"x11" eq [tk windowingsystem]} { %W yview scroll -5 units } } + bind Listbox { + if {!$tk_strictMotif} { + %W xview scroll -5 units + } + } bind Listbox <5> { if {!$tk_strictMotif} { %W yview scroll 5 units } } + bind Listbox { + if {!$tk_strictMotif} { + %W xview scroll 5 units + } + } } # ::tk::ListboxBeginSelect -- diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index ec14473..21eaa02 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk scrollbar widgets. # It also provides procedures that help in implementing the bindings. # -# RCS: @(#) $Id: scrlbar.tcl,v 1.13 2006/03/17 11:13:15 patthoyts Exp $ +# RCS: @(#) $Id: scrlbar.tcl,v 1.14 2008/12/28 23:43:14 dkf Exp $ # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. @@ -130,18 +130,34 @@ bind Scrollbar { tk::ScrollToPos %W 1 } } -if {[tk windowingsystem] eq "aqua"} { - bind Scrollbar { - tk::ScrollByUnits %W v [expr {- (%D)}] - } - bind Scrollbar { - tk::ScrollByUnits %W v [expr {-10 * (%D)}] +switch [tk windowingsystem] { + "aqua" { + bind Scrollbar { + tk::ScrollByUnits %W v [expr {- (%D)}] + } + bind Scrollbar { + tk::ScrollByUnits %W v [expr {-10 * (%D)}] + } + bind Scrollbar { + tk::ScrollByUnits %W h [expr {- (%D)}] + } + bind Scrollbar { + tk::ScrollByUnits %W h [expr {-10 * (%D)}] + } } - bind Scrollbar { - tk::ScrollByUnits %W h [expr {- (%D)}] + "win32" { + bind Scrollbar { + tk::ScrollByUnits %W v [expr {- (%D / 120) * 4}] + } + bind Scrollbar { + tk::ScrollByUnits %W h [expr {- (%D / 120) * 4}] + } } - bind Scrollbar { - tk::ScrollByUnits %W h [expr {-10 * (%D)}] + "x11" { + bind Scrollbar <4> {tk::ScrollByUnits %W v -5} + bind Scrollbar <5> {tk::ScrollByUnits %W v 5} + bind Scrollbar {tk::ScrollByUnits %W h -5} + bind Scrollbar {tk::ScrollByUnits %W h 5} } } # tk::ScrollButtonDown -- diff --git a/library/text.tcl b/library/text.tcl index 0d9b9d2..e4bd77d 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.42 2008/11/12 16:38:13 patthoyts Exp $ +# RCS: @(#) $Id: text.tcl,v 1.43 2008/12/28 23:43:14 dkf Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -471,6 +471,13 @@ if {[tk windowingsystem] eq "aqua"} { %W yview scroll [expr {(2-%D)/3}] pixels } } + bind Text { + if {%D >= 0} { + %W xview scroll [expr {-%D/3}] pixels + } else { + %W xview scroll [expr {(2-%D)/3}] pixels + } + } } if {"x11" eq [tk windowingsystem]} { @@ -488,6 +495,16 @@ if {"x11" eq [tk windowingsystem]} { %W yview scroll 50 pixels } } + bind Text { + if {!$tk_strictMotif} { + %W xview scroll -50 pixels + } + } + bind Text { + if {!$tk_strictMotif} { + %W xview scroll 50 pixels + } + } } # ::tk::TextClosestGap -- -- cgit v0.12