Fix cancel editing on Esc in wxOSX wxDataViewCtrl again
Handle selectors corresponding to key presses, such as cancelOperation:,
ourselves because we never get the keyDown events that are supposed to
take care of generating it from the native code somehow.
This fixes cancelling editing with Escape which stopped working since
26d6f82a81 (Implement EVT_CHAR generation for wxDataViewCtrl under Mac,
2021-04-13).
Closes #17835, #2639.
Co-Authored-By: Stefan Csomor <csomor@advancedconcepts.ch>
This commit is contained in:
@@ -375,6 +375,7 @@ public:
|
||||
typedef void (*wxOSX_EventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
|
||||
typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
|
||||
typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
|
||||
typedef void (*wxOSX_DoCommandBySelectorPtr)(NSView* self, SEL _cmd, SEL _sel);
|
||||
typedef NSDragOperation (*wxOSX_DraggingEnteredOrUpdatedHandlerPtr)(NSView *self, SEL _cmd, void *sender);
|
||||
typedef void (*wxOSX_DraggingExitedHandlerPtr)(NSView *self, SEL _cmd, void *sender);
|
||||
typedef BOOL (*wxOSX_PerformDragOperationHandlerPtr)(NSView *self, SEL _cmd, void *sender);
|
||||
|
||||
@@ -2005,12 +2005,23 @@ bool wxCocoaDataViewControl::doCommandBySelector(void* sel, WXWidget slf, void*
|
||||
{
|
||||
bool handled = wxWidgetCocoaImpl::doCommandBySelector(sel, slf, _cmd);
|
||||
// if this special key has not been handled
|
||||
if ( !handled && IsInNativeKeyDown() )
|
||||
if ( !handled )
|
||||
{
|
||||
// send the original key event back to the native implementation to get proper default handling like eg for arrow keys
|
||||
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:@selector(keyDown:)];
|
||||
superimpl(slf, @selector(keyDown:), GetLastNativeKeyDownEvent());
|
||||
if ( IsInNativeKeyDown() )
|
||||
{
|
||||
// send the original key event back to the native implementation to get proper default handling like eg for arrow keys
|
||||
wxOSX_EventHandlerPtr superimpl = (wxOSX_EventHandlerPtr) [[slf superclass] instanceMethodForSelector:@selector(keyDown:)];
|
||||
superimpl(slf, @selector(keyDown:), GetLastNativeKeyDownEvent());
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto superimpl = (wxOSX_DoCommandBySelectorPtr)
|
||||
[[slf superclass] instanceMethodForSelector:@selector(doCommandBySelector:)];
|
||||
if ( superimpl )
|
||||
superimpl(slf, @selector(doCommandBySelector:), (SEL)sel);
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user