Convert cocoa key down/up pressed event to equivalent Qt events
This commit is contained in:
parent
774aeaaf11
commit
399da3c7bc
32
3rdparty/qocoa/qsearchfield_mac.mm
vendored
32
3rdparty/qocoa/qsearchfield_mac.mm
vendored
@ -59,6 +59,22 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void keyDownPressed()
|
||||||
|
{
|
||||||
|
if (qSearchField) {
|
||||||
|
QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
|
||||||
|
QApplication::postEvent(qSearchField, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void keyUpPressed()
|
||||||
|
{
|
||||||
|
if (qSearchField) {
|
||||||
|
QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
|
||||||
|
QApplication::postEvent(qSearchField, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QPointer<QSearchField> qSearchField;
|
QPointer<QSearchField> qSearchField;
|
||||||
NSSearchField *nsSearchField;
|
NSSearchField *nsSearchField;
|
||||||
};
|
};
|
||||||
@ -79,6 +95,22 @@ public:
|
|||||||
pimpl->textDidChange(toQString([[notification object] stringValue]));
|
pimpl->textDidChange(toQString([[notification object] stringValue]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL)control: (NSControl *)control textView:
|
||||||
|
(NSTextView *)textView doCommandBySelector:
|
||||||
|
(SEL)commandSelector {
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (!pimpl) return NO;
|
||||||
|
|
||||||
|
if (commandSelector == @selector(moveDown:)) {
|
||||||
|
pimpl->keyDownPressed();
|
||||||
|
return YES;
|
||||||
|
} else if (commandSelector == @selector(moveUp:)) {
|
||||||
|
pimpl->keyUpPressed();
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
-(void)controlTextDidEndEditing:(NSNotification*)notification {
|
-(void)controlTextDidEndEditing:(NSNotification*)notification {
|
||||||
// No Q_ASSERT here as it is called on destruction.
|
// No Q_ASSERT here as it is called on destruction.
|
||||||
if (!pimpl) return;
|
if (!pimpl) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user