Re: Mac shortcut keys issue. Keys being sent to parent frame window.

Tony Kennedy <[email protected]> Tue, 25 Mar 2025 09:52:10 -0700 (PDT)
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
No problem.  I'm not familiar with objective C at all and not even sure if 
the code below is objective C or Swift.

I'm trying to trace things. In utils.m, I found the sendEvent function. And 
in it, there is a test for NSKeyUp, and the Apple docs say that it's 
depreciated. It also says there is an AppKit bug.

https://developer.apple.com/documentation/appkit/nskeyup

I tried replacing NSKeyUp with NSEvent.EventType.keyUp 
<https://developer.apple.com/documentation/appkit/nsevent/eventtype/keyup>, 
but it refuses to compile so I'm stuck.


/* This is needed because otherwise we don't receive any key-up events for 
command-key
 combinations (an AppKit bug, apparently) */
- (void)sendEvent:(NSEvent *)anEvent
{
    if ([anEvent type] == NSKeyUp && ([anEvent modifierFlags] & 
NSCommandKeyMask))
        [[self keyWindow] sendEvent:anEvent];
    else
        [super sendEvent:anEvent];    
}



On Tuesday, 25 March 2025 at 15:27:50 UTC Vadim Zeitlin wrote:

> On Tue, 25 Mar 2025 06:18:26 -0700 (PDT) Tony Kennedy wrote:
>
> TK> On the Mac, if I have a floating wxMiniFrame (or AUI panel) that 
> contains a 
> TK> text control, any shortcut keys (CMD-C, CMD-V etc) are sent to the 
> parent 
> TK> wxFrame window. 
>
> Sorry, I'm afraid this is one of these things that Mac just does
> differently, i.e. I believe that it sends accelerators from palette windows
> to the parent by default, and I have no idea about how to convince it not
> to do it, especially without breaking anything else.
>
> You probably need to track the key handling in wxOSX (setting
> WXTRACE=keyevent may help to see better what's going on) and try to find a
> place where the event handling diverges from the desired. Maybe this will
> give you an idea about how to change it.
>
> Sorry but this is all I can say without spending (much more) time (than I
> can afford) on this.
>
> Good luck!
> VZ
>
> -- 
> TT-Solutions: wxWidgets consultancy and technical support
> https://www.tt-solutions.com/
>

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/a3e3c10f-8a2b-4936-83d4-ffbf37cf6bb8n%40googlegroups.com.