+2004-12-05 Darin Adler <darin@apple.com>
+
+ - fixed small problem in my check-in from yesterday
+
+ * kwq/KWQEvent.mm:
+ (positionForEvent): Get location from event without raising exception if it's the wrong type.
+ (clickCountForEvent): Same, for clickCount.
+ (QMouseEvent::QMouseEvent): Use the new helper functions so this can be constructed even with
+ the wrong type of NSEvent. Required for cases where a keyboard event causes a "click" and we need
+ to synthesize a QMouseEvent for KHTML internal use, using the key down NSEvent.
+
2004-12-04 Darin Adler <darin@apple.com>
Reviewed by John.
return buttons;
}
+static QPoint positionForEvent(NSEvent *event)
+{
+ switch ([event type]) {
+ case NSLeftMouseDown:
+ case NSLeftMouseUp:
+ case NSLeftMouseDragged:
+ case NSRightMouseDown:
+ case NSRightMouseUp:
+ case NSRightMouseDragged:
+ case NSOtherMouseDown:
+ case NSOtherMouseUp:
+ case NSOtherMouseDragged:
+ return QPoint([event locationInWindow]);
+ default:
+ return QPoint();
+ }
+}
+
+static int clickCountForEvent(NSEvent *event)
+{
+ switch ([event type]) {
+ case NSLeftMouseDown:
+ case NSLeftMouseUp:
+ case NSLeftMouseDragged:
+ case NSRightMouseDown:
+ case NSRightMouseUp:
+ case NSRightMouseDragged:
+ case NSOtherMouseDown:
+ case NSOtherMouseUp:
+ case NSOtherMouseDragged:
+ return [event clickCount];
+ default:
+ return 0;
+ }
+}
+
// ========
QEvent::~QEvent()
QMouseEvent::QMouseEvent(Type type, NSEvent *event)
: QEvent(type)
- , _position([event locationInWindow])
+ , _position(positionForEvent(event))
, _button(mouseButtonForEvent(event))
, _state(nonMouseButtonsForEvent(event))
- , _clickCount([event clickCount])
+ , _clickCount(clickCountForEvent(event))
{
fixState();
}
{
NSEvent *event = [NSApp currentEvent];
if (event) {
- _position = QPoint([event locationInWindow]);
+ _position = positionForEvent(event);
_button = mouseButtonForEvent(event);
_state = nonMouseButtonsForEvent(event);
- _clickCount = [event clickCount];
+ _clickCount = clickCountForEvent(event);
}
fixState();
}