I am porting a carbon app to cocoa and have been unable to get a Declare to work. In the carbon app the user could double click on the title bar to collapse the content region leaving only the title bar visible and double click the bar again to expand it. In the “old days” this was a feature of the Mac OS; it was referred to as Window Shades. Since neither Xojo nor RealBasic provide mouse event in the title bar, I used the carbon function InstallEventHandler to get notified of the required events. This still works for getting application events but not for window events because the GetWindowEventTarget that is used in the process is now returning 0 when fed a cocoa window reference instead of a carbon window.
Cocoa provides a means to get window events with addLocalMonitorForEventsMatchingMask. Tell it which event(s) you want to be notified of (event masks) and it will call the handler/method you specify. It’s better than the carbon route because you are given the opportunity to return nil, which prevents the system from dispatching the event and allows you to assume responsibility for it (just love eating those tasty events).
Listed below are declarations in Objective C and Swift:
(Swift) class func addLocalMonitorForEventsMatchingMask(_ mask: NSEventMask, handler block: (NSEvent) -> NSEvent?) -> AnyObject?
(Objective C) (id)addLocalMonitorForEventsMatchingMask:(NSEventMask)mask handler:(NSEvent * _Nullable (^)(NSEvent *))block
I created a test app in Xcode using Swift and got it working but that didn’t help me with figuring out the declare in Xojo. I would appreciate it if somebody could show me a working declare for this.