Index: trunk/Cocoa/Pester/Source/NJRHotKeyField.m
===================================================================
--- trunk/Cocoa/Pester/Source/NJRHotKeyField.m	(revision 130)
+++ trunk/Cocoa/Pester/Source/NJRHotKeyField.m	(revision 131)
@@ -9,10 +9,6 @@
 #import "NJRHotKeyField.h"
 #import "NJRHotKeyFieldCell.h"
+#import "NJRHotKey.h"
 #import "NSString-NJRExtensions.h"
-
-// property list keys
-static NSString * const PLCharacters = @"characters"; // NSString
-static NSString * const PLModifierFlags = @"modifierFlags"; // NSNumber
-static NSString * const PLKeyCode = @"keyCode"; // NSNumber
 
 static const NSRange zeroRange = {0, 0};
@@ -48,4 +44,6 @@
 }
 
+#pragma mark initialize-release
+
 - (id)initWithCoder:(NSCoder *)coder;
 {
@@ -63,4 +61,11 @@
     return self;
 }
+
+- (void)dealloc;
+{
+    [hotKey release];
+}
+
+#pragma mark interface updating
 
 // XXX still problems with command-A the first time
@@ -85,9 +90,9 @@
 - (void)showKeyEquivalentAttributedStringFinalized:(BOOL)finalized;
 {
-    if (hotKeyCharacters == nil) {
+    if ([hotKey characters] == nil) {
         [self showStatus: @"none assigned"];
         return;
     }
-    NSMutableAttributedString *equivString = [[hotKeyCharacters keyEquivalentAttributedStringWithModifierFlags: hotKeyModifierFlags] mutableCopy];
+    NSMutableAttributedString *equivString = [[[hotKey characters] keyEquivalentAttributedStringWithModifierFlags: [hotKey modifierFlags]] mutableCopy];
     [equivString addAttribute: NSParagraphStyleAttributeName
                         value: (finalized ? centerAlignStyle : leftAlignStyle)
@@ -98,12 +103,5 @@
 }
 
-- (void)clearHotKey;
-{
-    [hotKeyCharacters release];
-    hotKeyCharacters = nil;
-    hotKeyModifierFlags = 0;
-    hotKeyCode = 0;
-    [NSApp sendAction: [self action] to: [self target] from: self];
-}
+#pragma mark event handling
 
 - (void)keyUp:(NSEvent *)theEvent;
@@ -122,8 +120,5 @@
             [self showStatus: message != nil ? message : @"key is unavailable for use"];
         } else {
-            [hotKeyCharacters release];
-            hotKeyCharacters = [characters retain];
-            hotKeyModifierFlags = modifierFlags;
-            hotKeyCode = [theEvent keyCode];
+            [self setHotKey: [NJRHotKey hotKeyWithCharacters: characters modifierFlags: modifierFlags keyCode: [theEvent keyCode]]];
             [NSApp sendAction: [self action] to: [self target] from: self];
             [self showKeyEquivalentAttributedStringFinalized: ([theEvent modifierFlags] & capturedModifierMask) == 0];
@@ -150,32 +145,28 @@
 }
 
+#pragma mark acccessing
+
+- (NJRHotKey *)hotKey;
+{
+    return hotKey;
+}
+
+- (void)setHotKey:(NJRHotKey *)aKey;
+{
+    if (aKey != hotKey) {
+        [hotKey release];
+        hotKey = [aKey retain];
+        [self showKeyEquivalentAttributedStringFinalized: ([[NSApp currentEvent] modifierFlags] & capturedModifierMask) == 0];
+    }
+}
+
+#pragma mark actions
+
 - (IBAction)clear:(id)sender;
 {
-    [self clearHotKey];
+    [self setHotKey: nil];
+    [NSApp sendAction: [self action] to: [self target] from: self];
     [self showKeyEquivalentAttributedStringFinalized: YES];
 }
 
-#pragma mark property list serialization (Pester 1.1)
-
-- (NSDictionary *)propertyListRepresentation;
-{
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-        hotKeyCharacters, PLCharacters,
-        [NSNumber numberWithUnsignedInt: hotKeyModifierFlags], PLModifierFlags,
-        [NSNumber numberWithUnsignedShort: hotKeyCode], PLKeyCode,
-        nil];
-}
-
-- (void)setFromPropertyList:(NSDictionary *)dict;
-{
-    NS_DURING
-        hotKeyCharacters = [[dict objectForKey: PLCharacters] retain];
-        hotKeyModifierFlags = [[dict objectForKey: PLModifierFlags] unsignedIntValue];
-        hotKeyCode = [[dict objectForKey: PLKeyCode] unsignedShortValue];
-        [self showKeyEquivalentAttributedStringFinalized: ([[NSApp currentEvent] modifierFlags] & capturedModifierMask) == 0];
-    NS_HANDLER
-        [self clear: nil];
-    NS_ENDHANDLER
-}
-
 @end
