Return bool from wxWidgetCocoaImpl::doCommandBySelector()
This allows to determine whether the event was handled by wx code and perform further processing by feeding things back to native code if not.
This commit is contained in:
committed by
Vadim Zeitlin
parent
d01760ae41
commit
18c45321f4
@@ -199,7 +199,8 @@ public :
|
|||||||
virtual void cursorUpdate(WX_NSEvent event, WXWidget slf, void* _cmd);
|
virtual void cursorUpdate(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||||
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||||
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
|
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
|
||||||
virtual void doCommandBySelector(void* sel, WXWidget slf, void* _cmd);
|
// Returns true if the event was processed by a user-defined event handler.
|
||||||
|
virtual bool doCommandBySelector(void* sel, WXWidget slf, void* _cmd);
|
||||||
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
||||||
|
@@ -2129,7 +2129,7 @@ void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::doCommandBySelector(void* sel, WXWidget slf, void* WXUNUSED(_cmd))
|
bool wxWidgetCocoaImpl::doCommandBySelector(void* sel, WXWidget slf, void* WXUNUSED(_cmd))
|
||||||
{
|
{
|
||||||
wxLogTrace(TRACE_KEYS, "Selector %s for %s",
|
wxLogTrace(TRACE_KEYS, "Selector %s for %s",
|
||||||
wxDumpSelector((SEL)sel), wxDumpNSView(slf));
|
wxDumpSelector((SEL)sel), wxDumpNSView(slf));
|
||||||
@@ -2139,23 +2139,25 @@ void wxWidgetCocoaImpl::doCommandBySelector(void* sel, WXWidget slf, void* WXUNU
|
|||||||
// it is also possible to map 1 keystroke to multiple commands, eg Ctrl-O on mac is translated to the bash-equivalent of
|
// it is also possible to map 1 keystroke to multiple commands, eg Ctrl-O on mac is translated to the bash-equivalent of
|
||||||
// execute and move back in history, since this results in two commands, Ctrl-O was sent twice as a wx key down event.
|
// execute and move back in history, since this results in two commands, Ctrl-O was sent twice as a wx key down event.
|
||||||
// we now track the sending of the events to avoid duplicates.
|
// we now track the sending of the events to avoid duplicates.
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
if ( IsInNativeKeyDown() && !WasKeyDownSent())
|
if ( IsInNativeKeyDown() && !WasKeyDownSent())
|
||||||
{
|
{
|
||||||
// If we have a corresponding key event, send wxEVT_KEY_DOWN now.
|
// If we have a corresponding key event, send wxEVT_KEY_DOWN now.
|
||||||
// (see also: wxWidgetCocoaImpl::DoHandleKeyEvent)
|
// (see also: wxWidgetCocoaImpl::DoHandleKeyEvent)
|
||||||
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
||||||
SetupKeyEvent( wxevent, GetLastNativeKeyDownEvent() );
|
SetupKeyEvent( wxevent, GetLastNativeKeyDownEvent() );
|
||||||
bool result = GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
handled = GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
||||||
|
|
||||||
if (!result)
|
if (!handled)
|
||||||
{
|
{
|
||||||
// Generate wxEVT_CHAR if wxEVT_KEY_DOWN is not handled.
|
// Generate wxEVT_CHAR if wxEVT_KEY_DOWN is not handled.
|
||||||
|
|
||||||
wxKeyEvent wxevent2(wxevent) ;
|
wxKeyEvent wxevent2(wxevent) ;
|
||||||
wxevent2.SetEventType(wxEVT_CHAR);
|
wxevent2.SetEventType(wxEVT_CHAR);
|
||||||
SetupKeyEvent( wxevent2, GetLastNativeKeyDownEvent() );
|
SetupKeyEvent( wxevent2, GetLastNativeKeyDownEvent() );
|
||||||
GetWXPeer()->OSXHandleKeyEvent(wxevent2);
|
handled = GetWXPeer()->OSXHandleKeyEvent(wxevent2);
|
||||||
}
|
}
|
||||||
SetKeyDownSent();
|
SetKeyDownSent();
|
||||||
}
|
}
|
||||||
@@ -2163,6 +2165,8 @@ void wxWidgetCocoaImpl::doCommandBySelector(void* sel, WXWidget slf, void* WXUNU
|
|||||||
{
|
{
|
||||||
wxLogTrace(TRACE_KEYS, "Doing nothing in doCommandBySelector:");
|
wxLogTrace(TRACE_KEYS, "Doing nothing in doCommandBySelector:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
|
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
|
||||||
|
Reference in New Issue
Block a user