Annotation of Examples/AppKit/BusyBox/BusyBoxApp.m, revision 1.1.1.1

1.1       root        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: {
                     29:     if (!infoPanel) {
                     30:        if (![self loadNibSection:"InfoPanel.nib" owner:self withNames:NO]) {
                     31:            NXLogError ("Could not load InfoPanel.nib");
                     32:        }
                     33:     }
                     34:     [infoPanel makeKeyAndOrderFront:self];
                     35:     return self;
                     36: }
                     37: 
                     38: - preferences:sender
                     39: /*
                     40:  * The preferences panel is a separate nib module and only loaded on demand.
                     41:  */
                     42: {
                     43:     if (!prefPanel) {
                     44:        if (![self loadNibSection:"PrefPanel.nib" owner:self withNames:NO]) {
                     45:            NXLogError ("Could not load PrefPanel.nib");
                     46:        }
                     47:     }
                     48:     [prefPanel makeKeyAndOrderFront:self];
                     49:     return self;
                     50: }
                     51: 
                     52: 
                     53: 
                     54: - appDidInit:sender;
                     55: /* Upon starting, app asks Help object to bring up help panel and display the
                     56:  * general help information.
                     57:  */
                     58: {
                     59:     [helpObject generalHelp:self];
                     60:     return self;
                     61: }
                     62: 
                     63: - sendEvent:(NXEvent *)event;
                     64: /* I override sendEvent: so that I can snarf control-mouseDown events.
                     65:  * When the user holds Control key down and clicks on something, this
                     66:  * method will figure out which window received the click, finds the
                     67:  * view which is directly under the mouse down, and passes that information
                     68:  * to the help object who will display the appropriate help file.  If this
                     69:  * isn't a control-mouseDown event, I just call the super Application 
                     70:  * sendEvent: method to handle the event normally.
                     71:  */
                     72:  {    
                     73:     id window,view;
                     74: 
                     75:     if ((event->type == NX_LMOUSEDOWN) && (event->flags & NX_CONTROLMASK)) {
                     76:         window = [self findWindow:event->window];
                     77:        view = [[window contentView] hitTest:&event->location];
                     78:        if (view) [helpObject helpForView:view atPoint:&event->location];
                     79:        else [helpObject helpForWindow:window];
                     80:     }
                     81:     else [super sendEvent:event];
                     82:     return self;
                     83: }
                     84: 
                     85: @end

unix.superglobalmegacorp.com

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