Re: Carbon Events vs Cocoa Events
Re: Carbon Events vs Cocoa Events
- Subject: Re: Carbon Events vs Cocoa Events
- From: "Erik M. Buck" <email@hidden>
- Date: Mon, 1 Apr 2002 13:53:58 -0600
----- Original Message -----
From: "Charles Srstka" <email@hidden>
To: "Bill Bumgarner" <email@hidden>
>
The question is, how do you have some method or function get called
>
whenever an event occurs in Cocoa? In Carbon, it's easy, because you can
You don't. the existence of non-user input events on a particular platform
is an implementation detail that is not appropriate at the level of Cocoa.
Cocoa exists to abstract stuff like that away. That is
one of the reasons Cocoa has historically had cross platform support.
Objective-C messaging eliminates the need for most types of "event" used in
procedural languages and impaired object oriented languages.
>
just do whatever you want with the EventRecord that you get from
>
WaitNextEvent (in the old model - I don't know much about the new one to
>
comment on it). How could you make a simple app in Cocoa that logged all
>
events, for example? I can do that in Carbon, but I have no idea how it
>
would be done in Cocoa.
Why would you want to do that ? The ApplicationKit handles events for you
and provides hooks to let you perform processing that you might want to
perform.
Apple events are handled specially by Cocoa. I am not an expert on
Apple events, but I believe that built in support for Apple events in Cocoa
exceeds the built in support in Carbon.
For non-Apple events, see the NSWorkspace and NSFileManager classes as well
as NSApplication
notifications. Cocoa handles events for you and provides hooks for
you to do your own thing without having to do message translation yourself.
I am sure there are holes and/or areas that are considered too low level for
Cocoa applications. Input handlers and drivers exist for these functions.
In practice, those components are not any lower level than Carbon so there
should be no objection to using them.
What is wrong with
NSApplicationDidChangeScreenParametersNotification and
NSWorkspaceWillPowerOffNotification and NSWorkspaceWillUnmountNotification,
and NSWorkspaceWillLaunchApplicationNotification, and
NSWorkspaceDidTerminateApplicationNotification, and
NSWorkspaceDidMountNotification, and
NSWorkspaceDidLaunchApplicationNotification, etc. ?
Not everyone has to use Cocoa. If Cocoa does not
conform to your mental model of how things should work, just don't use it.
Carbon may suit you better. These things are partly a matter of taste. I
personally think that exposing the level of detail that you want would ruin
Cocoa.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.