summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--library/demos/cscroll.tcl16
-rw-r--r--macosx/tkMacOSXCarbonEvents.c4
-rw-r--r--macosx/tkMacOSXMouseEvent.c42
4 files changed, 59 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index ef1966c..b6bcf52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-12-13 Daniel Steffen <das@users.sourceforge.net>
+
+ * library/demos/cscroll.tcl: add MouseWheel bindings for aqua.
+
+ * macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents):
+ * macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent,
+ GenerateMouseWheelEvent): add support for kEventMouseScroll events
+ (smooth mouse wheel scrolling from mighty mouse or scrolling trackpad)
+ by handling kEventMouseWheelMoved on application target as well as on
+ dispatcher, in order to pick up synthesized MouseWheel events from
+ HIObject handler (c.f. QA1453); add support for horizontal scrolling
+ events by generating MouseWheel XEvent with Shift modifier.
+
2005-12-12 Jeff Hobbs <jeffh@ActiveState.com>
* unix/tcl.m4, unix/configure: Fix sh quoting error reported in
@@ -55,7 +68,7 @@
* macosx/tkMacOSXInit.c: only remaining tcl internals in TkAqua are
* macosx/tkMacOSXNotify.c: TclServiceIdle() in tkMacOSXScrlbr.c and
* macosx/tkMacOSXScrlbr.c: Tcl_Get/SetStartupScript() in tkMacOSXInit.c
- [Bug 1336531].
+ [RFE 1336531].
* macosx/tkMacOSXInt.h: sync comments with core-8-4-branch.
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl
index 9e6600c..7ad390a 100644
--- a/library/demos/cscroll.tcl
+++ b/library/demos/cscroll.tcl
@@ -3,7 +3,7 @@
# This demonstration script creates a simple canvas that can be
# scrolled in two dimensions.
#
-# RCS: @(#) $Id: cscroll.tcl,v 1.5 2004/12/21 11:56:35 dkf Exp $
+# RCS: @(#) $Id: cscroll.tcl,v 1.6 2005/12/13 03:44:34 das Exp $
if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
@@ -60,6 +60,20 @@ $c bind all <Any-Leave> "scrollLeave $c"
$c bind all <1> "scrollButton $c"
bind $c <2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
+if {[tk windowingsystem] eq "aqua"} {
+ bind $c <MouseWheel> {
+ %W yview scroll [expr {- (%D)}] units
+ }
+ bind $c <Option-MouseWheel> {
+ %W yview scroll [expr {-10 * (%D)}] units
+ }
+ bind $c <Shift-MouseWheel> {
+ %W xview scroll [expr {- (%D)}] units
+ }
+ bind $c <Shift-Option-MouseWheel> {
+ %W xview scroll [expr {-10 * (%D)}] units
+ }
+}
proc scrollEnter canvas {
global oldFill
diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c
index a8b752c..c4aca8d 100644
--- a/macosx/tkMacOSXCarbonEvents.c
+++ b/macosx/tkMacOSXCarbonEvents.c
@@ -60,7 +60,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.7 2005/12/01 06:24:16 hobbs Exp $
+ * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.8 2005/12/13 03:44:34 das Exp $
*/
#include "tkInt.h"
@@ -193,6 +193,7 @@ TkMacOSXInitCarbonEvents (
{kEventClassMenu, kEventMenuBeginTracking},
{kEventClassMenu, kEventMenuEndTracking},
{kEventClassCommand, kEventCommandProcess},
+ {kEventClassMouse, kEventMouseWheelMoved},
{kEventClassWindow, kEventWindowExpanded},
{kEventClassApplication, kEventAppHidden},
{kEventClassApplication, kEventAppShown},
@@ -231,6 +232,7 @@ TkMacOSXInitCarbonEvents (
_TraceEventByName(CFSTR("kEventMouseDown"));
_TraceEventByName(CFSTR("kEventMouseUp"));
_TraceEventByName(CFSTR("kEventMouseWheelMoved"));
+ _TraceEventByName(CFSTR("kEventMouseScroll"));
_TraceEventByName(CFSTR("kEventWindowUpdate"));
_TraceEventByName(CFSTR("kEventWindowActivated"));
_TraceEventByName(CFSTR("kEventWindowDeactivated"));
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index ea9919d..b5f7a06 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.15 2005/11/27 02:36:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.16 2005/12/13 03:44:34 das Exp $
*/
#include "tkInt.h"
@@ -128,7 +128,7 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
Point where, where2;
int xOffset, yOffset, result;
TkDisplay * dispPtr;
- OSStatus status;
+ OSStatus status;
MouseEventData mouseEventData, * medPtr = &mouseEventData;
switch (eventPtr->eKind) {
@@ -208,17 +208,24 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
}
if (eventPtr->eKind == kEventMouseWheelMoved) {
status = GetEventParameter(eventPtr->eventRef,
- kEventParamMouseWheelDelta,
- typeLongInteger, NULL,
+ kEventParamMouseWheelDelta, typeLongInteger, NULL,
sizeof(long), NULL, &medPtr->delta);
if (status != noErr ) {
#ifdef TK_MAC_DEBUG
- fprintf (stderr,
- "Failed to retrieve mouse wheel delta, %d\n", (int) status);
+ fprintf (stderr,
+ "Failed to retrieve mouse wheel delta, %d\n", (int) status);
#endif
- statusPtr->err = 1;
- return false;
- }
+ statusPtr->err = 1;
+ return false;
+ } else {
+ EventMouseWheelAxis axis;
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL,
+ sizeof(EventMouseWheelAxis), NULL, &axis);
+ if (status == noErr && axis == kEventMouseWheelAxisX) {
+ medPtr->state |= ShiftMask;
+ }
+ }
}
dispPtr = TkGetDisplayList();
@@ -226,11 +233,15 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
if (eventPtr->eKind != kEventMouseDown) {
/*
- * MouseMoved, MouseDragged or kEventMouseWheelMoved
+ * MouseMoved, MouseDragged or MouseWheelMoved
*/
if (eventPtr->eKind == kEventMouseWheelMoved) {
- return GenerateMouseWheelEvent(medPtr);
+ int res = GenerateMouseWheelEvent(medPtr);
+ if (res) {
+ statusPtr->stopProcessing = 1;
+ }
+ return res;
} else {
return GeneratePollingEvents(medPtr);
}
@@ -534,7 +545,6 @@ static int
GenerateMouseWheelEvent(MouseEventData * medPtr)
{
Tk_Window tkwin, rootwin, grabWin;
- int local_x, local_y;
TkDisplay *dispPtr;
TkWindow *winPtr;
XEvent xEvent;
@@ -550,7 +560,7 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
} else {
tkwin = Tk_TopCoordsToWindow(rootwin,
medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
+ &xEvent.xbutton.x, &xEvent.xbutton.y);
}
}
@@ -565,12 +575,14 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
tkwin = grabWin;
}
if (!tkwin) {
- return true;
+ return false;
}
winPtr = (TkWindow *) tkwin;
xEvent.type = MouseWheelEvent;
xEvent.xkey.keycode = medPtr->delta;
- xEvent.xbutton.state = TkMacOSXButtonKeyState();
+ xEvent.xbutton.x_root = medPtr->global.h;
+ xEvent.xbutton.y_root = medPtr->global.v;
+ xEvent.xbutton.state = medPtr->state;
xEvent.xany.serial = LastKnownRequestProcessed(winPtr->display);
xEvent.xany.send_event = false;
xEvent.xany.display = winPtr->display;