Annotation of Examples/AppKit/CalculatorLab/MinusPanel.m, revision 1.1.1.1

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: #import "MinusPanel.h"
                      9: 
                     10: @implementation MinusPanel
                     11: 
                     12: // When the user presses the minus sign on the keypad, the resulting character
                     13: // is number 45 from the Symbol character set, not a minus sign from the ASCII
                     14: // character set (which you would get by pressing the key to the right of the 
                     15: // zero key).  The Panel class ignores commandKeys from all sets except the 
                     16: // ASCII set, but we want the user to be able to depress the minus key on the
                     17: // keypad and have it act like the real minus key.  We can get around this
                     18: // problem by checking for this special minus sign and converting it into an
                     19: // ASCII minus sign before it reaches the regular commandKey: method
                     20: - (BOOL)commandKey:(NXEvent *)theEvent
                     21: {
                     22:     NXEvent localEvent;
                     23:     BOOL    symbolSet, minusSign;
                     24:     
                     25:     symbolSet = theEvent->data.key.charSet == NX_SYMBOLSET;
                     26:     minusSign = theEvent->data.key.charCode == 45;
                     27: 
                     28:     if (symbolSet && minusSign) {  /* check for minus */
                     29:        localEvent = *theEvent;
                     30:        localEvent.data.key.charSet = NX_ASCIISET;
                     31:        localEvent.data.key.charCode = '-';
                     32:        return [super commandKey:&localEvent];
                     33:     } else {
                     34:         return [super commandKey:theEvent];
                     35:     }
                     36: }
                     37: 
                     38: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.