GDCarbonEvent Class Reference

The GDCarbonEvent is an object wrapper for using carbon events. More...

#import <GDCarbonEvent.h>

List of all members.

Public Member Functions

(id) - initWithCoder:
 Initialize this GDCarbonEvent with a coder.
(void) - encodeWithCoder:
 Writes the keyCode, and modifierFlags to the coder.
(void) - setHotKeySignature:
 Set the hotkey signature for a carbon hot key event.
(void) - setHotKeyId:
 Set the hotkey id for a carbon hot key event.
(int) - hotKeyId
 The hotkey id.
(void) - setEventClass:
 Sets the event class for a carbon event.
(void) - setEventKind:
 Set's the event kind for a carbon event.
(void) - setEventClass:andEventKind:
 Set the event class and event kind for a carbon event.
(NSUInteger) - cocoaModifierKeys
 Returns the modifier keys converted into a cocoa modifier int.
(void) - install
 Installs the event.
(void) - uninstall
 Uninstalls the event.
(void) - invoke
 Performs the callback action desired, either target/action or notification.
(id) - initWithEventClass:andEventKind:
 Initialize with event class, and event kind.
(void) - setNotificationName:andNotificationCenter:
 Set the notification name, and notification center if you want this event to post notifications.
(void) - setAction:andTarget:
 Set the action and target for this event if you want the callback to call a selector.
(void) - setKeyCode:andFlags:areFlagsCocoa:
 Set keycode, and modifier flags, optionally tell it that the flags were cocoa and need to be converted to carbon modifier flags.
(NSString *) - keyString
 This returns a string that represents the value of the keyCode, and modifier keys all added together: keyCode+modifiers.

Static Public Member Functions

(void) + disposeOfLookupManager
 Disposes of an internal static lookup dictionary that's used for all GDCarbonEvents.

Protected Attributes

Boolean isInstalled
 Whether or not the event is installed with the carbon event manager.
NSStringsigString
 The event signature string.
EventHandlerRef eventRef
 An event handler reference.
EventHandlerUPP handlerUPP
 A function pointer to the internal callback (Universal Precedure Pointer).
EventTypeSpec eventSpec
 Describes the class and kind of event.
EventHotKeyRef hotKeyRef
 A reference to a global hot key event.
EventHotKeyID hotKeyId
 A global hot key event id.

Properties

NSStringkeyChar
 An NSString for the key char - like 'W', 'F', etc.
NSStringnotificationName
 The notification name, if this carbon event is posting to a notification center.
NSNotificationCenter * notificationCenter
 The nofication center to post to.
SEL action
 Selector to callback, if this event is NOT posting to a notification center.
id target
 The target for the selector.
int keyCode
 ASCII Key code for carbon event HotKey.
int modifierFlags
 Modifier keys for a carbon hot key event (cmdKey, optionKey, shiftKey, optionKey, controlKey, kFunctionKeyCharCode).
NSDictionary * userInfo
 User info dict that get's passed back to the callback, or passed as userInfo in the notification.

Detailed Description

The GDCarbonEvent is an object wrapper for using carbon events.

This also wraps up creating carbon global hot key events.

See also:
http://dbachrach.com/blog/2005/11/28/program-global-hotkeys-in-cocoa-easily/
http://cocoasamurai.blogspot.com/2009/03/global-keyboard-shortcuts-with-carbon.html

Member Function Documentation

+ (void) disposeOfLookupManager  

Disposes of an internal static lookup dictionary that's used for all GDCarbonEvents.

You only need to use this if you use a GDCarbonEvent, then stop using it and need to be sure all memory associated with a GDCarbonEvent is freed.

- (void) encodeWithCoder: (NSCoder *)  coder  

Writes the keyCode, and modifierFlags to the coder.

It doesn't write anything else in the coder.

Parameters:
coder An NSCoder.
- (id) initWithCoder: (NSCoder *)  coder  

Initialize this GDCarbonEvent with a coder.

It only sets up the keyCode, and modifierFlags from the coder. You need to continue initializing the object to setup action/target and other parameters.

Parameters:
coder An NSCoder.
- (id) initWithEventClass: (FourCharCode)  eventClass
andEventKind: (NSUInteger)  eventKind 

Initialize with event class, and event kind.

Parameters:
eventClass An event class.
eventKind An event kind.
- (void) invoke  

Performs the callback action desired, either target/action or notification.

Target/selector takes precedence if both target/sel and notifications are set.

- (void) setAction: (SEL)  action
andTarget: (id)  target 

Set the action and target for this event if you want the callback to call a selector.

Parameters:
action The action to call.
target The target that contains the selector.
- (void) setEventClass: (FourCharCode)  eventClass  

Sets the event class for a carbon event.

Parameters:
eventClass An event class.
- (void) setEventClass: (FourCharCode)  eventClass
andEventKind: (NSUInteger)  eventKind 

Set the event class and event kind for a carbon event.

Parameters:
eventClass An event class.
eventKind An event kind.
- (void) setEventKind: (NSUInteger)  eventKind  

Set's the event kind for a carbon event.

Parameters:
eventKind An event kind.
- (void) setHotKeyId: (int)  kid  

Set the hotkey id for a carbon hot key event.

Parameters:
kid The hotkey id.
- (void) setHotKeySignature: (NSString *)  signature  

Set the hotkey signature for a carbon hot key event.

Parameters:
signature An NSString to use for the signature - this should be at max 4 characters - it's converted into a FourCharCode.
- (void) setKeyCode: (NSUInteger)  code
andFlags: (NSUInteger)  flags
areFlagsCocoa: (Boolean)  cocoaFlags 

Set keycode, and modifier flags, optionally tell it that the flags were cocoa and need to be converted to carbon modifier flags.

Parameters:
code The key char code.
flags Any modifier flags (0 if none).
cocoaFlags Whether or not the flags came from the cocoa representation or modifier flags, if so they will be converted to carbon
- (void) setNotificationName: (NSString *)  name
andNotificationCenter: (NSNotificationCenter *)  center 

Set the notification name, and notification center if you want this event to post notifications.

Parameters:
name The notification name to post.
center The NSNotificationCenter to post to.

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Properties Defines