home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Examples / AppKit / BusyBox / BusyBoxApp.m < prev    next >
Text File  |  1992-06-16  |  2KB  |  85 lines

  1. /*
  2.  * This subclass only adds a few responsibilities to the Application 
  3.  * class. It loads the info and preferences panels on demand, 
  4.  * and overrides sendEvent: to watch for control-mouseDown events
  5.  * 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 <appkit/appkit.h>
  14. #import "BusyBoxApp.h"
  15. #import "Help.h"
  16. #import <strings.h>
  17. #import <libc.h>        // for chdir, getwd
  18.  
  19.  
  20. @implementation BusyBoxApp
  21.  
  22. /* TARGET/ACTION METHODS */
  23.  
  24. - info:sender
  25. /*
  26.  * The info panel is a separate nib module and only loaded on demand.
  27.  */
  28. {(' if (!infoPanel) {
  29.     if (![self loadNibSection:"InfoPanel.nib" owner:self withNames:NO]) {
  30.         NXLogError ("Could not load InfoPanel.nib");
  31.     }
  32.     }
  33.     [infoPanel makeKeyAndOrderFront:self];
  34.     return self;
  35. }
  36.  
  37. - preferences:sender
  38. /*
  39.  * The preferences panel is a separate nib module and only loaded on demand.
  40.  */
  41. {
  42.     if (!prefPanel) {
  43.     if (![self loadNibSection:"PrefPanel.nib" owner:self withNames:NO]) {
  44.         NXLogError ("Could not load PrefPanel.nib");
  45.     }
  46.     }
  47.     [prefPanel makeKeyAndOrderFront:self];
  48.     return self;
  49. }
  50.  
  51.  
  52.  
  53. - appDidInit:sender;
  54. /* Upon starting, app asks Help object to bring up help panel and display the
  55.  * general help information.
  56.  */
  57. {
  58.     [helpObject generalHelp:self];
  59.     return self;
  60. }
  61.  
  62. - sendEvent:(NXEvent *)event;
  63. /* I override sendEvent: so that I can snarf control-mouseDown events.
  64.  * When the user holds Control key down and clicks on something, this
  65.  * method will figure out which window received the click, finds the
  66.  * view which is directly under the mouse down, and passes that information
  67.  * to the help object who will display the appropriate help file.  If this
  68.  * isn't a control-mouseDown event, I just call the super Application 
  69.  * sendEvent: method to handle the event normally.
  70.  */
  71.  {    
  72.     id window,view;
  73.  
  74.     if ((event->type == NX_LMOUSEDOWN) && (event->flags & NX_CONTROLMASK)) {
  75.         window = [self findWindow:event->window];
  76.     view = [[window contentView] hitTest:&event->location];
  77.     if (view) [helpObject helpForView:view atPoint:&event->location];
  78.     else [helpObject helpForWindow:window];
  79.     }
  80.     else [super sendEvent:event];
  81.     return self;
  82. }
  83.  
  84. @end
  85.