home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Chemistry / Elements_1.0 / Elements.app / sources / ElementApp.m < prev    next >
Text File  |  1992-02-08  |  2KB  |  63 lines

  1. /*
  2.  * This subclass only adds a few responsibilities to the Application class.
  3.  * It loads the info and preferences panels on demand, keeps track of the 
  4.  * path to the app wrapper, and overrides sendEvent: to watch for 
  5.  * control-mouseDown events which it vectors off to the help object.
  6.  *
  7.  * Author: Julie Zelenski, NeXT Developer Support
  8.  * You may freely copy, distribute and reuse the code in this example.  
  9.  * NeXT disclaims any warranty of any kind, expressed or implied, as to 
  10.  * its fitness for any particular use.
  11.  */
  12.  
  13. #import "Boss.h"
  14. #import "ElementApp.h"
  15. #import <appkit/View.h>
  16. #import <strings.h>
  17. #import <appkit/defaults.h>      // for NXArgv
  18. #import <libc.h>        // for chdir, getwd
  19.  
  20.  
  21. @implementation ElementApp:Application
  22.  
  23. + new;
  24. /* New is overridden so the BusyBoxApp gets and saves the path to executable.
  25.  * The help object will ask the app for this, so it can find the help
  26.  * files which are in a directory in the app wrapper. 
  27.  */
  28. {
  29.     char *suffix;
  30.     
  31.     self = [super new];
  32.     strcpy(appDirectory, NXArgv[0]);
  33.     if (suffix = rindex(appDirectory,'/')) 
  34.         *suffix  = '\0';     /* remove executable name */
  35.     if (appDirectory) chdir(appDirectory); 
  36.     getwd(appDirectory);
  37.     return self;
  38. }
  39.  
  40.  
  41. - (const char *)appDirectory;
  42. /* Returns the path to the app wrapper (for Help object).
  43.  */
  44. {
  45.     return appDirectory;
  46. }
  47.  
  48. - sendEvent:(NXEvent *)event;
  49. // I override sendEvent: so that I can snarf arrowkey events in tableWin.
  50. {    
  51.     id window;
  52.  
  53.     if ((event->type == NX_KEYDOWN) 
  54.             && (tableWin == (window = [self findWindow:event->window]))) {        
  55.         [theBoss keyEvent:event];
  56.     }
  57.     else [super sendEvent:event];
  58.     return self;
  59. }
  60.  
  61.  
  62. @end
  63.