Re: Carbon Events vs Cocoa Events
Re: Carbon Events vs Cocoa Events
- Subject: Re: Carbon Events vs Cocoa Events
- From: Charles Srstka <email@hidden>
- Date: Tue, 2 Apr 2002 01:14:37 -0600
On Monday, April 1, 2002, at 01:53 PM, Erik M. Buck wrote:
----- 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.
Heh, I think you misunderstand me a bit... I didn't say that Cocoa
"didn't conform to my mental model of how things should work." I use
Cocoa, and couldn't write a Carbon app of anything near the complexity
of my current Cocoa projects for the life of me, nor would I want to.
Hell, I put off learning GUI programming until Mac OS X came out (and I
waited years for this). I like Cocoa, otherwise I wouldn't be on this
list, :-) and all my major projects are in Cocoa.
I merely said that for *one particular, specialized purpose* that I
*didn't know how to do something* in Cocoa that I could in Carbon. I
asked if there was a way to do it in Cocoa, because I was curious.
Nothing more, nothing less. Turns out it was possible, and due to the
help of some people on this list, I now have a working Cocoa app that
does precisely what I wanted, which was to have a little diagnostic
utility to help me learn some things about how some parts of the
operating system worked, because I was curious. That's all. The new
Cocoa app even works better than my old Carbon app did anyway.
I learned quite a bit from this discussion, and I'm glad we had it.
Isn't that a major purpose of this board? Education? It is for me.
Please, don't get offended so easily. We're all friends here. :-) Right?
Charles
_______________________________________________
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.