|
|
Sample Programs from NeXSTEP 3.3
// MinusPanel.m
//
// You may freely copy, distribute and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to
// its fitness for any particular use.
//
extern "Objective-C"
{
#import "MinusPanel.h"
}
@implementation MinusPanel
// When the user presses the minus sign on the keypad, the resulting character
// is number 45 from the Symbol character set, not a minus sign from the ASCII
// character set (which you would get by pressing the key to the right of the
// zero key). The Panel class ignores commandKeys from all sets except the
// ASCII set, but we want the user to be able to depress the minus key on the
// keypad and have it act like the real minus key. We can get around this
// problem by checking for this special minus sign and converting it into an
// ASCII minus sign before it reaches the regular commandKey: method
- (BOOL)commandKey:(NXEvent *)theEvent
{
NXEvent localEvent;
BOOL symbolSet, minusSign;
symbolSet = theEvent->data.key.charSet == NX_SYMBOLSET;
minusSign = theEvent->data.key.charCode == 45;
if (symbolSet && minusSign) { /* check for minus */
localEvent = *theEvent;
localEvent.data.key.charSet = NX_ASCIISET;
localEvent.data.key.charCode = '-';
return [super commandKey:&localEvent];
} else {
return [super commandKey:theEvent];
}
}
@end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.