kEventMouseUp with HIViews in a window

Member
Posts: 129
Joined: 2005.02
Post: #1
Hello all,

I posted this to carbon-dev@lists.apple.com, but I only received one reply. I am testing Carbon out to judge whether or not I want to do my next project with it. I currently use Cocoa . I am curious if it is possible to receive any kEventMouseUp events to a window that has HIView's embedded within. I am running into an issue where I cannot receive any mouse up events because the HIView does not generate these (correct?). I know if I do not use the compositing attribute, and HIViews, I do get kEventMouseUp events sent to the window event handler. I need to receive mouse ups, as we do our own input handling--a simple content click will not do.

Thanks,
Mark
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
you need to go back to Cocoa and subclass NSApplicationto get full control over event handling like this.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
I assume it's possible in Carbon, but as Unknown proves, people know the answers in Cocoa Wink
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #4
In Cocoa it's super easy. Just override NSApplication -sendEvent: (NSEvent *) and switch on [event type] to get mouse down, mouse up, etc. You can then capture what you need from the event and forward it to your app logic. In your switch's default case, call [super sendEvent: event] and you're good to go.

I don't know how familiar you are with Cocoa, but if you override NSApplication, you will need to set your NSApplication subclass as the "principle class" in the app's info.plist
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #5
Yes, I'm well aware on how to do this in Cocoa. I currently do intercept the NSApplication events. However, I wanted to move the entire project in Carbon. I thought it was a bit odd to do everything in Carbon, and then use Cocoa for the main event handling.

Either way, I've just went with not compositing the game window. I have other windows that do use HIViews and compositing--the just cannot intercept kEventMouseUp events. Which is okay, I suppose. I don't see those windows being a huge input priority in terms of receiving mouse up events, althought it would have been nice to have one event solution for every window.

I've had a lot of headaches incorporating Cocoa with our existing codebase. While the solution worked find, for one reason or another I do not enjoy mixing the paradigms of C++ and Objective-C.

EDIT: I dont remember posting 131 times. I can wear it's more like 13 Smile
Quote this message in a reply
Post Reply