diff options
author | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-12-12 15:24:34 +0000 |
---|---|---|
committer | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-12-12 15:24:34 +0000 |
commit | 2e8516354aacef064d01425808da06d2cdcb4791 (patch) | |
tree | 9da4758828930280d32f18d54ece7a249df742c7 /AppKit/GTMHotKeyTextField.h | |
parent | 9f64d056dd70f2f938ac6f5adb8e75b650dc2e1a (diff) |
- GTMStackTrace works on 10.5+ (and iPhone) using NSThread to build the call stack.
- Added GTM_EXTERN that makes it easier to mix and match objc and objc++ code.
- Added GTMHotKeysTextField for display and editing of hot key settings.
- Added GTMCarbonEvent for dealing with Carbon Events and HotKeys in a ObjC like way.
- Backported the Atomic Barrier Swap functions for Objective C back to Tiger.
- Added a variety of new functions to GTMUnitTestingUtilities for checking if the screensaver is in the way, waiting on user events, and generating keystrokes.
- If you are using any Carbon routines that log (DebugStr, AssertMacros.h) and use GTMUnitTestDevLog, the log routines now go through _GTMDevLog so that they can be caught in GTMUnitTestDevLog and verified like any _GTMDevLog calls you may make. For an example of this in action see GTMCarbonEventTest.m.
- Added GTMFileSystemKQueue. It provides a simple wrapper for kqueuing something in the file system and tracking changes to it.
- RunIPhoneUnitTest.sh now cleans up the user home directory and creates a documents directory within it, used when requesting a NSDocumentDirectory.
- Added GTMNSFileManager+Carbon which contains routines for path <-> Alias conversion and path <-> FSRef conversion.
- Added GTMNSArray+Merge for merging one array into another with or without a custom merging function, returning a new array with the merged contents.
Diffstat (limited to 'AppKit/GTMHotKeyTextField.h')
-rw-r--r-- | AppKit/GTMHotKeyTextField.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/AppKit/GTMHotKeyTextField.h b/AppKit/GTMHotKeyTextField.h new file mode 100644 index 0000000..4177f49 --- /dev/null +++ b/AppKit/GTMHotKeyTextField.h @@ -0,0 +1,127 @@ +// +// GTMHotKeyTextField.h +// +// Copyright 2006-2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +// Text field for capturing hot key entry. This is intended to be similar to the +// Apple key editor in their Keyboard pref pane. + +// NOTE: There are strings that need to be localized to use this field. See the +// code in stringForKeycode the the keys. The keys are all the English versions +// so you'll get reasonable things if you don't have a strings file. + +#import <Cocoa/Cocoa.h> +#import "GTMDefines.h" + +// Dictionary key for hot key configuration information modifier flags. +// NSNumber of a unsigned int. Modifier flags are stored using Cocoa constants +// (same as NSEvent) you will need to translate them to Carbon modifier flags +// for use with RegisterEventHotKey() +#define kGTMHotKeyModifierFlagsKey @"Modifiers" + +// Dictionary key for hot key configuration of virtual key code. NSNumber of +// unsigned int. For double-modifier hotkeys (see below) this value is ignored. +#define kGTMHotKeyKeyCodeKey @"KeyCode" + +// Dictionary key for hot key configuration of double-modifier tap. NSNumber +// BOOL value. Double-tap modifier keys cannot be used with +// RegisterEventHotKey(), you must implement your own Carbon event handler. +#define kGTMHotKeyDoubledModifierKey @"DoubleModifier" + +// Custom text field class used for hot key entry. In order to use this class +// you will need to configure your window's delegate, to return the related +// field editor. +// +// Sample window delegate method: +// +// -(id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject { +// +// if ([anObject isKindOfClass:[GTMHotKeyTextField class]]) { +// return [GTMHotKeyFieldEditor sharedHotKeyFieldEditor]; +// } else { +// return nil; // Window will use the AppKit shared editor +// } +// +// } +// +// +// Other notes: +// - Though you are free to implement control:textShouldEndEditing: in your +// delegate its return is always ignored. The field always accepts only +// one hotkey keystroke before editing ends. +// - The "value" binding of this control is to the dictionary describing the +// hotkey. At this time binding options are not supported. +// - The field does not attempt to consume all hotkeys. Hotkeys which are +// already bound in Apple prefs or other applications will have their +// normal effect. +// + +@interface GTMHotKeyTextField : NSTextField { + @private + NSDictionary *hotKeyDict_; + // Bindings + NSObject *boundObject_; + NSString *boundKeyPath_; +} + +// Set/Get the hot key dictionary for the field. See above for key names. +- (void)setHotKeyValue:(NSDictionary *)hotKey; +- (NSDictionary *)hotKeyValue; + +// Convert Cocoa modifier flags (-[NSEvent modifierFlags]) into a string for +// display. Modifiers are represented in the string in the same order they would +// appear in the Menu Manager. +// +// Args: +// flags: -[NSEvent modifierFlags] +// +// Returns: +// Autoreleased NSString +// ++ (NSString *)stringForModifierFlags:(unsigned int)flags; + +// Convert a keycode into a string that would result from typing the keycode in +// the current keyboard layout. This may be one or more characters. +// +// Args: +// keycode: Virtual keycode such as one obtained from NSEvent +// useGlyph: In many cases the glyphs are confusing, and a string is clearer. +// However, if you want to display in a menu item, use must +// have a glyph. Set useGlyph to FALSE to get localized strings +// which are better for UI display in places other than menus. +// bundle: Localization bundle to use for localizable key names +// +// Returns: +// Autoreleased NSString +// ++ (NSString *)stringForKeycode:(UInt16)keycode + useGlyph:(BOOL)useGlyph + resourceBundle:(NSBundle *)bundle; + +@end + +// Custom field editor for use with hotkey entry fields (GTMHotKeyTextField). +// See the GTMHotKeyTextField for instructions on using from the window +// delegate. +@interface GTMHotKeyFieldEditor : NSTextView { + @private + NSDictionary *hotKeyDict_; // strong +} + +// Get the shared field editor for all hot key fields ++ (GTMHotKeyFieldEditor *)sharedHotKeyFieldEditor; + +@end |