From 6b8cb98d74ed7563290ff2fe719b4694ef5de02c Mon Sep 17 00:00:00 2001 From: wolfsuit Date: Mon, 16 Feb 2004 23:09:23 +0000 Subject: This gets the scroll wheel working for listboxes and text widgets for Mac OS X. It also changes the model to route scrollwheel events to the window under the pointer, not the focus window on X (and only on X). That is the correct behavior for Mac OS X. --- ChangeLog | 23 +++++++++++++++++++---- generic/tkEvent.c | 7 ++++++- library/listbox.tcl | 13 ++++++++++--- library/text.tcl | 13 ++++++++++--- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index b06da65..11c7232 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-02-16 Jim Ingham + + Fix for MouseWheel Events (from Daniel Steffen): + + * generic/tkEvent.c (Tk_HandleEvent): On Mac OS X, don't route + MouseWheel events to the Focus window. They are sent to the + window under the pointer on X (and the GenerateMouseWheelEvent + already got this right.) + * library/listbox.tcl: On Mac OS, don't use the magic 120 + divisor that is used on Windows. We may come up with a cleaner + way to do this for the TOT, but this is simple and will do for the + 8.4 branch. + * library/text.tcl: Ditto. + 2004-02-15 Jim Ingham Backport Mac OS X specific fixes from TOT: @@ -7,10 +21,11 @@ * macosx/tkMacOSXKeyboard.c: Add PowerBook keycode 0x34 as . [Benjamin Riefenstahl] - * macosx/tkMacOSXScrlbr.c: Reworking Vince's fix to [Bug 842952]. This - version is clearer, and works helps keep the mouse better pinned to the - scrollbar. I also removed the glitch where the scrollbar would jump get - its middle over the mouse when you first moved it. + * macosx/tkMacOSXScrlbr.c: Reworking Vince's fix to [Bug 842952]. + This version is clearer, and works helps keep the mouse better + pinned to the scrollbar. I also removed the glitch where the + scrollbar would jump get its middle over the mouse when you first + moved it. * macosx/tkMacOSXClipboard.c (TkSuspendClipboard, TkSelGetSelection): add unicode clipboard support. [Patch #840107] (senn) diff --git a/generic/tkEvent.c b/generic/tkEvent.c index f3b61d6..117f873 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkEvent.c,v 1.17.2.1 2003/07/19 01:03:25 hobbs Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.17.2.2 2004/02/16 23:09:25 wolfsuit Exp $ */ #include "tkPort.h" @@ -838,7 +838,12 @@ Tk_HandleEvent(eventPtr) * available on the Windows version of Tk. */ +#ifdef MAC_OSX_TK + /* MouseWheel events are not focus specific on Mac OS X */ + if (mask & (KeyPressMask|KeyReleaseMask)) { +#else if (mask & (KeyPressMask|KeyReleaseMask|MouseWheelMask)) { +#endif winPtr->dispPtr->lastEventTime = eventPtr->xkey.time; winPtr = TkFocusKeyEvent(winPtr, eventPtr); if (winPtr == NULL) { diff --git a/library/listbox.tcl b/library/listbox.tcl index ff3b549..dcc3cde 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.13 2002/08/31 06:12:28 das Exp $ +# RCS: @(#) $Id: listbox.tcl,v 1.13.2.1 2004/02/16 23:09:25 wolfsuit Exp $ # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994-1995 Sun Microsystems, Inc. @@ -179,8 +179,15 @@ bind Listbox { # someone could use the "event generate" command to produce one # on other platforms. -bind Listbox { - %W yview scroll [expr {- (%D / 120) * 4}] units +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { + bind Listbox { + %W yview scroll [expr {- (%D)}] units + } +} else { + bind Listbox { + %W yview scroll [expr {- (%D / 120) * 4}] units + } } if {[string equal "x11" [tk windowingsystem]]} { diff --git a/library/text.tcl b/library/text.tcl index eb227c2..85d83f1 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.24 2002/08/31 06:12:28 das Exp $ +# RCS: @(#) $Id: text.tcl,v 1.24.2.1 2004/02/16 23:09:25 wolfsuit Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -458,8 +458,15 @@ set ::tk::Priv(prevPos) {} # someone could use the "event generate" command to produce one # on other platforms. -bind Text { - %W yview scroll [expr {- (%D / 120) * 4}] units +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { + bind Text { + %W yview scroll [expr {- (%D)}] units + } +} else { + bind Text { + %W yview scroll [expr {- (%D / 120) * 4}] units + } } if {[string equal "x11" [tk windowingsystem]]} { -- cgit v0.12