summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorrjohnson <rjohnson>1998-10-10 00:30:34 (GMT)
committerrjohnson <rjohnson>1998-10-10 00:30:34 (GMT)
commit6b30648b424171905375ec916ab86186a3043dfc (patch)
tree5d1b6c4f80c96cbc9337259a6d98a40a78aff79b /generic
parent733f2ab4691d31c0fdca72da988c5f4878ee5709 (diff)
downloadtk-6b30648b424171905375ec916ab86186a3043dfc.zip
tk-6b30648b424171905375ec916ab86186a3043dfc.tar.gz
tk-6b30648b424171905375ec916ab86186a3043dfc.tar.bz2
Added support for the MouseWheel event.
Diffstat (limited to 'generic')
-rw-r--r--generic/tk.h11
-rw-r--r--generic/tkBind.c29
-rw-r--r--generic/tkEvent.c13
3 files changed, 40 insertions, 13 deletions
diff --git a/generic/tk.h b/generic/tk.h
index ddfd176..de694ae 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tk.h,v 1.13 1998/09/30 19:01:19 rjohnson Exp $
+ * RCS: @(#) $Id: tk.h,v 1.14 1998/10/10 00:30:35 rjohnson Exp $
*/
#ifndef _TK
@@ -416,11 +416,14 @@ typedef struct Tk_GeomMgr {
#define VirtualEvent (LASTEvent)
#define ActivateNotify (LASTEvent + 1)
#define DeactivateNotify (LASTEvent + 2)
-#define TK_LASTEVENT (LASTEvent + 3)
+#define MouseWheelEvent (LASTEvent + 3)
+#define TK_LASTEVENT (LASTEvent + 4)
+
+#define MouseWheelMask (1L << 28)
-#define VirtualEventMask (1L << 30)
#define ActivateMask (1L << 29)
-#define TK_LASTEVENT (LASTEvent + 3)
+#define VirtualEventMask (1L << 30)
+#define TK_LASTEVENT (LASTEvent + 4)
/*
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 6fcafd2..8166b18 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -6,11 +6,12 @@
*
* Copyright (c) 1989-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
+ * Copyright (c) 1998 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkBind.c,v 1.3 1998/09/14 18:23:03 stanton Exp $
+ * RCS: @(#) $Id: tkBind.c,v 1.4 1998/10/10 00:30:36 rjohnson Exp $
*/
#include "tkPort.h"
@@ -495,6 +496,7 @@ static EventInfo eventArray[] = {
{"Colormap", ColormapNotify, ColormapChangeMask},
{"Activate", ActivateNotify, ActivateMask},
{"Deactivate", DeactivateNotify, ActivateMask},
+ {"MouseWheel", MouseWheelEvent, MouseWheelMask},
{(char *) NULL, 0, 0}
};
static Tcl_HashTable eventTable;
@@ -567,7 +569,8 @@ static int flagArray[TK_LASTEVENT] = {
/* MappingNotify */ 0,
/* VirtualEvent */ VIRTUAL,
/* Activate */ ACTIVATE,
- /* Deactivate */ ACTIVATE
+ /* Deactivate */ ACTIVATE,
+ /* MouseWheel */ KEY
};
/*
@@ -2394,6 +2397,13 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr)
case 'B':
number = eventPtr->xcreatewindow.border_width;
goto doNumber;
+ case 'D':
+ /*
+ * This is used only by the MouseWheel event.
+ */
+
+ number = eventPtr->xkey.keycode;
+ goto doNumber;
case 'E':
number = (int) eventPtr->xany.send_event;
goto doNumber;
@@ -3164,7 +3174,7 @@ HandleEventGenerate(interp, mainwin, argc, argv)
flags = flagArray[event.xany.type];
if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
event.xkey.state = pat.needMods;
- if (flags & KEY) {
+ if ((flags & KEY) && (event.xany.type != MouseWheelEvent)) {
/*
* When mapping from a keysym to a keycode, need information about
* the modifier state that should be used so that when they call
@@ -3279,6 +3289,15 @@ HandleEventGenerate(interp, mainwin, argc, argv)
} else {
goto badopt;
}
+ } else if (strcmp(field, "-delta") == 0) {
+ if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if ((flags & KEY) && (event.xkey.type == MouseWheelEvent)) {
+ event.xkey.keycode = number;
+ } else {
+ goto badopt;
+ }
} else if (strcmp(field, "-detail") == 0) {
number = TkFindStateNum(interp, field, notifyDetail, value);
if (number < 0) {
@@ -3315,7 +3334,7 @@ HandleEventGenerate(interp, mainwin, argc, argv)
if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY) {
+ if ((flags & KEY) && (event.xkey.type != MouseWheelEvent)) {
event.xkey.keycode = number;
} else {
goto badopt;
@@ -3353,7 +3372,7 @@ HandleEventGenerate(interp, mainwin, argc, argv)
break;
}
}
- if (flags & KEY) {
+ if ((flags & KEY) && (event.xkey.type != MouseWheelEvent)) {
event.xkey.keycode = number;
} else {
goto badopt;
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index 2e32b8f..6403001 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -6,11 +6,12 @@
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright (c) 1998 by Scriptics Corporation.
*
* 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.2 1998/09/14 18:23:09 stanton Exp $
+ * RCS: @(#) $Id: tkEvent.c,v 1.3 1998/10/10 00:30:36 rjohnson Exp $
*/
#include "tkPort.h"
@@ -129,7 +130,8 @@ static unsigned long eventMasks[TK_LASTEVENT] = {
0, /* Mapping Notify */
VirtualEventMask, /* VirtualEvents */
ActivateMask, /* ActivateNotify */
- ActivateMask /* DeactivateNotify */
+ ActivateMask, /* DeactivateNotify */
+ MouseWheelMask /* MouseWheelEvent */
};
/*
@@ -546,10 +548,13 @@ Tk_HandleEvent(eventPtr)
/*
* Redirect KeyPress and KeyRelease events to the focus window,
- * or ignore them entirely if there is no focus window.
+ * or ignore them entirely if there is no focus window. We also
+ * route the MouseWheel event to the focus window. The MouseWheel
+ * event is an extension to the X event set. Currently, it is only
+ * available on the Windows version of Tk.
*/
- if (mask & (KeyPressMask|KeyReleaseMask)) {
+ if (mask & (KeyPressMask|KeyReleaseMask|MouseWheelMask)) {
winPtr->dispPtr->lastEventTime = eventPtr->xkey.time;
winPtr = TkFocusKeyEvent(winPtr, eventPtr);
if (winPtr == NULL) {