|
|
Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: Re: Getting character info out of EventRef - msg#00223
List: carbon-dev
On 2009-05-25, at 23:33:33, Ken Tozier wrote: I need to write a category that does basically the same thing as the Leopard-only NSEvent eventWithEventRef: and in looking over the Carbon documentation, it seems really awkward to get info from an EventRef. â Really, the only field in that group that I'm interested in is "charactersIgnoringModifiers" but I don't know if the other fields are absolute requirements. If they are, Is there any wat to get that info? I think that would be to use UCKeyTranslate() but I note the documentation (since I'm not really familiar with [NSEvent: keyEventWithType:â]) says: "unmodCharacters The string of characters generated by the key event as if no modifier key had been pressed ( except for Shift). This argument is useful for getting the âbasicâ key value in a hardware-independent manner." So there may be some fiddling with the modifiers to produce the correct value for the Cocoa method. I don't deal with Carbon very much, but this seems like an awful lot of code to do something so simple. Even OS 7.x EventRecord struct put EventRefs to shame in the ease of use department. It's not a simple thing anymore. Philip Aker echo astwta@xxxxxxxxx@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (Carbon-dev@xxxxxxxxxxxxxxx)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/maillists%40codeha.us
This email sent to maillists@xxxxxxxxx
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Getting character info out of EventRef
Ken,
On May 25, 2009, at 11:33 PM, Ken Tozier wrote:
I need to write a category that does basically the same thing as the
Leopard-only NSEvent eventWithEventRef: and in looking over the
Carbon documentation, it seems really awkward to get info from an
EventRef.
The fields I need to get to create an NSEvent are:
[NSEvent keyEventWithType: NSKeyDown
location:(NSPoint)location
modifierFlags: modifierKeys
timestamp:(NSTimeInterval) GetEventTime(inEventRef)
windowNumber:(NSInteger)windowNum
context:(NSGraphicsContext *)context
characters: charString
charactersIgnoringModifiers:(NSString *)unmodCharacters
isARepeat:(BOOL)repeatKey
keyCode:(unsigned short)code];
I see that there a few dedicated functions for some fields like
GetEventKind
GetEventTime
And I can get the modifier flags and character using
GetEventParameter(inEventRef,
kEventParamKeyModifiers,
typeUInt32,
NULL,
sizeof(modifierKeys),
NULL,
&modifierKeys);
GetEventParameter(inEventRef,
kEventParamKeyMacCharCodes,
typeChar,
NULL,
sizeof(keyChar),
NULL,
&keyChar);
but that leaves the following fields with no obvious way to assemble
the information
location
windowNumber
context
charactersIgnoringModifiers
keyCode
Really, the only field in that group that I'm interested in is
"charactersIgnoringModifiers" but I don't know if the other fields
are absolute requirements. If they are, Is there any wat to get that
info?
I don't know what requirements there are for creating an NSEvent.
Yes, there is a way to get the info, but exactly how depends on what
kind of event you got. What is the target of your event?
I don't deal with Carbon very much, but this seems like an awful lot
of code to do something so simple. Even OS 7.x EventRecord struct
put EventRefs to shame in the ease of use department.
1 API is too much code? Good luck getting any of this info out of an
EventRecord. sheesh. If you really want to try then use
ConvertEventRefToEventRecord().
Is there some chapter I'm missing that makes it all easy?
There is the Carbon Event Manager Documentation:
<http://developer.apple.com/documentation/Carbon/Conceptual/Carbon_Event_Manager/Intro/CarbonEventsIntro.html
>
And there is the Carbon Event API Reference:
<http://developer.apple.com/documentation/Carbon/Reference/Carbon_Event_Manager_Ref/Reference/reference.html
>
And you should also read Carbon.framework/Frameworks/
HIToolbox.framework/Headers/CarbonEvents.h & CarbonEventCore.h from
top to bottom.
More later,
Jack
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (Carbon-dev@xxxxxxxxxxxxxxx)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/maillists%40codeha.us
This email sent to maillists@xxxxxxxxx
Next Message by Date:
click to view message preview
Re: Getting character info out of EventRef
On May 26, 2009, at 3:46 AM, Jack Small wrote:
I don't know what requirements there are for creating an NSEvent.
Yes, there is a way to get the info, but exactly how depends on what
kind of event you got. What is the target of your event?
1 API is too much code? Good luck getting any of this info out of
an EventRecord. sheesh. If you really want to try then use
ConvertEventRefToEventRecord().
An NSObject subclass that handles special command keys inside another
application. As to the one API ... not trying to dis Carbon, Iit's
very useful for those ares that haven't been implemented in Cocoa yet,
but in the specific case of event refs, accessing the bread and butter
event fields really isn't very elegant.
Compare Cocoa
modifiers = [event modifiers];
OS 7
eventRecord->modifiers;
To Carbon:
GetEventParameter(inEventRef,
kEventParamKeyModifiers,
typeUInt32,
NULL,
sizeof(modifierKeys),
NULL,
&modifierKeys);
Thanks for the heads up on the ConvertEventRefToEventRecord function
though. That looks like a nice way to reduce 5 individual 7 argument
function calls to one.
-Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (Carbon-dev@xxxxxxxxxxxxxxx)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/maillists%40codeha.us
This email sent to maillists@xxxxxxxxx
Previous Message by Thread:
click to view message preview
Re: Getting character info out of EventRef
On 2009-05-26, at 01:28:25, Ken Tozier wrote:
[â]
As to the one API ... not trying to dis Carbon, Iit's very useful
for those ares that haven't been implemented in Cocoa yet, but in
the specific case of event refs, accessing the bread and butter
event fields really isn't very elegant.
Compare Cocoa
modifiers = [event modifiers];
OS 7
eventRecord->modifiers;
To Carbon:
GetEventParameter(inEventRef,
kEventParamKeyModifiers,
typeUInt32,
NULL,
sizeof(modifierKeys),
NULL,
&modifierKeys);
To CarbonEventsCore:
UInt32 GetCurrentEventKeyModifiers(void); //(Read the discussion in
the header).
Â
I disagree with your remark about elegance. You're speaking from the
perspective of someone just dropping in -- not someone who intends to
work in the medium. A major point about Carbon is consistency on a
large scale and specifically with events, naming conventions that are
arguably the best on the planet. The implementation is such that
developers have flexibility to structure things according to the
considerations they have at hand. Most folks using Carbon as their
major expression would have Get/Set wrappers for their top 100 needs
because obviously, if you're not doing a query for type or size, you
can wrap the function so that the size and type are auto-calculated. /
Developer/Examples/Carbon/HIFramework/TEventHandler.h is a starter
example for wrapping the EventRef APIs in C++.
Philip Aker
echo astwta@xxxxxxxxx@nl | tr a-z@. p-za-o.@
Democracy: Two wolves and a sheep voting on lunch.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (Carbon-dev@xxxxxxxxxxxxxxx)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/maillists%40codeha.us
This email sent to maillists@xxxxxxxxx
Next Message by Thread:
click to view message preview
Re: Getting character info out of EventRef
I sent this reply to Ken but neglected to send it to the list.On May 26, 2009, at 2:33 AM, Ken Tozier wrote:I need to write a category that does basically the same thing as the Leopard-only NSEvent eventWithEventRef: and in looking over the Carbon documentation, it seems really awkward to get info from an EventRef.I believe everything you're looking for is in the Quartz Event Taps API. Read about it in Apple's "Quartz Event Services Reference" document. You can learn more by downloading my free Event Taps Testbench application at prefabsoftware.com/eventtapstestbench.Look particularly at CGEventGetIntegerValueField and related functions, and the long list of constants in CGEventField.This is a C API, but it's not that hard to use if you have some familiarity with Core Foundation conventions.--Bill Cheesemanbill@xxxxxxxxxxxxxx _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (Carbon-dev@xxxxxxxxxxxxxxx)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/maillists%40codeha.us
This email sent to maillists@xxxxxxxxx
|
|