My application uses Chromium Embedded Framework(CEF) which requires NSApplication to implement a protocol which involves overriding [NSApplication sendEvent] so that a scoped object is created on a call to sendEvent. (for example, java-cef/util_mac.mm at master · chromiumembedded/java-cef · GitHub ) Events sent to CEF need to be within the lifetime of the scoped object.
I’ve run into a similar issue in the past. The easy solution was to override the method I needed in a category. This does produce a compiler warning, but you can #pragma that away or disable that warning…
Unfortunately, this is also what java-CEF is doing, so im not sure how you would ensure that your override is the one that would be called. Unless your whole point was to call the java-CEF version. if that is the case, then this should just work without you needing to write any code, which I imagine is the whole reason java-CEF is using a category to do this rather than subclassing.
if that is the case, then this should just work without you needing to write any code, which I imagine is the whole reason java-CEF is using a category to do this rather than subclassing.
Yes, overriding NSApplication already works. The problem is that I want the scoped object to be created when SDLApplication processes the event(the call to Cocoa_DispatchEvent) because that’s when the event gets sent to CEF.
Right now, with the approach from the java-cef link above, the scoped object gets created when [NSApplication sendEvent] gets called after the call to Cocoa_DispatchEvent, but by then event is already sent to CEF.