• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to intercept all events in a Carbon/Cocoa app?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to intercept all events in a Carbon/Cocoa app?


  • Subject: How to intercept all events in a Carbon/Cocoa app?
  • From: "v. Anderson Wiese 2" <email@hidden>
  • Date: Mon, 12 Feb 2007 17:48:04 -0600

Greetings,

My question in a nutshell: how do I intercept every Cocoa event in hybrid Carbon/Cocoa application?

I'm new to Cocoa and Obj C, and I am tasked with hosting cocoa windows within an existing Carbon application with some odd event dispatching requirements. In this app, a set of cooperative threads are responsible for handling their own UI, such that each UI event (CarbonEvent, in the typical case) is received in the main thread, its target is determined, the event is queued to the appropriate thread, then the cooperative thread is resumed and the event is dispatched within that context. As long as the threads are strictly cooperative, this works well enough in Carbon, and I now have to figure out how to do the equivalent in Cocoa.

We could have a lively discussion about how such a thing came about, but I have already failed many times to advocate some simpler architecture, and my employers aren't going to pay me to commiserate with ya'll.

I thought that the best way to intercept and micro-manage every event in Cocoa is to override sendEvent in a subclass of NSApplication. It seems to require some trickery to do this in a Carbon app that calls NSApplicationLoad. I have opted for using the poseAsClass trick suggested by Finaly Dobbie in http://lists.apple.com/archives/cocoa- dev/2004/May/msg02078.html. I found another way, using a category to replace [NSApplication sharedApplication], but that seemed scarier since I was guessing at exactly what sharedApplication needs to do. Is there a better way?

What events should I expect to run through [MyNSApp sendEvent]? I have implemented this in the CocoaInCarbon sample project, and it seems to only work partially. I see some events in sendEvent; e.g. when the app is activated, when the window is moved, and key events. But notably, I don't see any mouse events. The cocoa window functions normally, so the events are going somewhere. What do I need to do to see all events for the cocoa app from a single bottleneck?

I will very much appreciate any suggestions!

Andy Wiese

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Running from DMG
  • Next by Date: Re: Enabled Binding on Controls
  • Previous by thread: Modelling a small unchanging set of possibilities (Core Data)
  • Next by thread: NSTextField help
  • Index(es):
    • Date
    • Thread