|
|
1.1 ! root 1: // MinusPanel.m ! 2: // ! 3: // You may freely copy, distribute and reuse the code in this example. ! 4: // NeXT disclaims any warranty of any kind, expressed or implied, as to ! 5: // its fitness for any particular use. ! 6: // ! 7: ! 8: extern "Objective-C" ! 9: { ! 10: #import "MinusPanel.h" ! 11: } ! 12: ! 13: @implementation MinusPanel ! 14: ! 15: // When the user presses the minus sign on the keypad, the resulting character ! 16: // is number 45 from the Symbol character set, not a minus sign from the ASCII ! 17: // character set (which you would get by pressing the key to the right of the ! 18: // zero key). The Panel class ignores commandKeys from all sets except the ! 19: // ASCII set, but we want the user to be able to depress the minus key on the ! 20: // keypad and have it act like the real minus key. We can get around this ! 21: // problem by checking for this special minus sign and converting it into an ! 22: // ASCII minus sign before it reaches the regular commandKey: method ! 23: - (BOOL)commandKey:(NXEvent *)theEvent ! 24: { ! 25: NXEvent localEvent; ! 26: BOOL symbolSet, minusSign; ! 27: ! 28: symbolSet = theEvent->data.key.charSet == NX_SYMBOLSET; ! 29: minusSign = theEvent->data.key.charCode == 45; ! 30: ! 31: if (symbolSet && minusSign) { /* check for minus */ ! 32: localEvent = *theEvent; ! 33: localEvent.data.key.charSet = NX_ASCIISET; ! 34: localEvent.data.key.charCode = '-'; ! 35: return [super commandKey:&localEvent]; ! 36: } else { ! 37: return [super commandKey:theEvent]; ! 38: } ! 39: } ! 40: ! 41: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.