home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / Misc / HigherEducationMailbox.mbox / Archives_provide_val_.attach / May_91 / appkit.595 < prev    next >
Text File  |  1991-05-21  |  1KB  |  39 lines

  1. {\rtf0\ansi{\fonttbl\f2\fnil Times-Roman;\f3\fmodern Courier;\f0\fswiss Helvetica;}
  2. \paperw11760
  3. \paperh7200
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f2\b0\i0\ul0\fs28 Symbol font Alternate characters\
  8. \
  9. Q:  
  10. \fc0 Alongside the keyboard map in the User Reference Guide, it states that programs might, as a convenience, provide Symbol font characters for certain Alternate key combinations when typing in other font families.  How does a developer implement this convenience?\
  11. \
  12. A:  Basically, your strategy is to override 
  13. \b keyDown
  14. \b0 : in a Text subclass and check if the character belongs to the Symbol set of characters.  If so, you insert a font change to Symbol, go ahead and process the keyDown:, and then restore the original font family.  Here's the code to do this:\
  15. \
  16.  
  17. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f3\fs24\fc0 - keyDown:(NXEvent *)theEvent\
  18. \{\
  19.     id oldFont,newFont;\
  20. \
  21.     if (theEvent->data.key.charSet == NX_SYMBOLSET) \{\
  22.         oldFont = typingRun.font;\
  23.     newFont = [Font newFont:"Symbol" size:[oldFont pointSize]];\
  24.     [self setSelFont:newFont];\
  25.     [super keyDown:theEvent];\
  26.     [self setSelFont:oldFont];\
  27.     \} else\
  28.         [super keyDown:theEvent];\
  29.     return self;\
  30. \}\
  31.  
  32. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f2\fs28 \
  33. QA595\
  34. \
  35. Valid for 1.0\
  36. Valid for 2.0  \
  37. \
  38.  
  39.