summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2020-09-16 01:23:01 (GMT)
committermarc_culler <marc.culler@gmail.com>2020-09-16 01:23:01 (GMT)
commit0a2028696498075a876a3a507484ef9ebfcf1dd6 (patch)
tree3764f1ac72cfbc47cf96aa92e20deee22f197e2e
parentb64a5a5eac960a2b2d4ac92330811743117ca6cf (diff)
downloadtk-0a2028696498075a876a3a507484ef9ebfcf1dd6.zip
tk-0a2028696498075a876a3a507484ef9ebfcf1dd6.tar.gz
tk-0a2028696498075a876a3a507484ef9ebfcf1dd6.tar.bz2
Deal with the deprecation of the context property of mouse NSEvents.
-rw-r--r--macosx/tkMacOSXMouseEvent.c4
-rw-r--r--macosx/tkMacOSXTest.c30
2 files changed, 20 insertions, 14 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 00477dd..804531b 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -72,11 +72,11 @@ enum {
* If this event is not for a Tk toplevel, it should just be passed up the
* responder chain. However, there is an exception for synthesized events,
* which are used in testing. Those events are recognized by having their
- * (unused) context pointer set to 1.
+ * both the windowNumber and the eventNumber set to -1.
*/
if (eventWindow && ![eventWindow isMemberOfClass:[TKWindow class]]) {
- if ([theEvent context] != (void *) 1)
+ if ([theEvent windowNumber] != -1 || [theEvent eventNumber] != -1)
return theEvent;
}
diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c
index 16fe37e..7981f7e 100644
--- a/macosx/tkMacOSXTest.c
+++ b/macosx/tkMacOSXTest.c
@@ -197,7 +197,8 @@ PressButtonObjCmd(
int objc,
Tcl_Obj *const objv[])
{
- int x = 0, y = 0, i, value, wNum;
+ int x = 0, y = 0, i, value;
+ NSInteger signal = -1;
CGPoint pt;
NSPoint loc;
NSEvent *motion, *press, *release;
@@ -231,15 +232,20 @@ PressButtonObjCmd(
pt.x = loc.x = x;
pt.y = y;
loc.y = ScreenHeight - y;
- wNum = 0;
+
+ /*
+ * We set the window number and the eventNumber to -1 as a signal to
+ * processMouseEvent.
+ */
+
CGWarpMouseCursorPosition(pt);
motion = [NSEvent mouseEventWithType:NSMouseMoved
location:loc
modifierFlags:0
timestamp:GetCurrentEventTime()
- windowNumber:wNum
- context:(void *) 1
- eventNumber:0
+ windowNumber:signal
+ context:nil
+ eventNumber:signal
clickCount:1
pressure:0.0];
[NSApp postEvent:motion atStart:NO];
@@ -247,19 +253,19 @@ PressButtonObjCmd(
location:loc
modifierFlags:0
timestamp:GetCurrentEventTime()
- windowNumber:wNum
- context:(void *)1
- eventNumber:1
+ windowNumber:signal
+ context:nil
+ eventNumber:signal
clickCount:1
- pressure:-1.0];
+ pressure:0.0];
[NSApp postEvent:press atStart:NO];
release = [NSEvent mouseEventWithType:NSLeftMouseUp
location:loc
modifierFlags:0
timestamp:GetCurrentEventTime()
- windowNumber:wNum
- context:(void*) 1
- eventNumber:2
+ windowNumber:signal
+ context:nil
+ eventNumber:signal
clickCount:1
pressure:-1.0];
[NSApp postEvent:release atStart:NO];