If an event listener is marked to dequeue, dequeue even if the event does not match the mask

* Note that this does not match the Cocoa documentation, but a whole bunch of event handling code relies on this behavior, so I have to keep it the way it was.
* Fixed dequeue flag in CPApplication -runModalSession:
* Added a window title in CPAlertTest
This commit is contained in:
Aparajita Fishman
2013-01-31 16:33:33 +08:00
parent 952fd59c42
commit 64d1465dfe
2 changed files with 18 additions and 8 deletions
+15 -7
View File
@@ -556,7 +556,7 @@ CPRunContinuesResponse = -1002;
// [theWindow._bridge _obscureWindowsBelowModalWindow];
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:NO];
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:YES];
}
/*!
@@ -619,14 +619,22 @@ CPRunContinuesResponse = -1002;
if (_eventListeners.length)
{
if (_eventListeners[_eventListeners.length - 1]._mask & (1 << [anEvent type]))
{
var listener = _eventListeners.pop();
listener._callback(anEvent);
var listener = _eventListeners[_eventListeners.length - 1];
if (listener._dequeue)
return;
if (listener._mask & (1 << [anEvent type]))
{
_eventListeners.pop();
listener._callback(anEvent);
}
/*
FIXME: This does not match Cocoa documented behavior for the dequeue
flag. Cocoa says the event is dequeued only if it matches the mask.
Unfortunately event handling code in Cappuccino is depending
on an event being dequeued even if it does not match.
*/
if (listener._dequeue)
return;
}
if ([anEvent type] == CPMouseMoved)
+3 -1
View File
@@ -44,7 +44,9 @@
[CPDocModalWindowMask, CPCriticalAlertStyle]
];
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(100,100,500,500) styleMask:CPTitledWindowMask];
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(100, 100, 500, 500) styleMask:CPTitledWindowMask];
[theWindow setTitle:@"CPAlert Test"];
var contentView = [theWindow contentView];
label = [[CPTextField alloc] initWithFrame:CGRectMake(15, 15, 400, 24)];