home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / NeXTanswers / AsciiFiles / Questions_and_Answers / NEXTSTEP_Developer / AppKit / 1525_isTestingInterface.txt < prev    next >
Encoding:
Text File  |  1994-02-25  |  1.6 KB  |  28 lines

  1. Q:  I would like to have an object in my custom palette do something different when it is unarchived in test mode in Interface Builder.  How can I determine if I am in test mode?
  2.  
  3. A:  You can use the isTestingInterface method which is defined in the IB (Interface Builder) protocol.  See /NextLibrary/Documentation/NextDev/GeneralRef/08_InterfaceBuilder/Protocols/IB.rtf:
  4.  
  5. Protocol Description
  6.  
  7. Interface Builder's subclass of the Application class conforms to this protocol.  Thus, objects in your custom palette can interact with Interface Builder's main module by sending messages (corresponding to the methods in this protocol) to NXApp. 
  8.  
  9. isTestingInterface
  10. - (BOOL)isTestingInterface
  11.  
  12. Returns YES if Interface Builder is in Test mode.
  13.  
  14. However, there is a bug with the isTestingInterface method in Release 3.1 and after.  Even in test mode,  [NXApp isTestingInterface] always yields NO during unarchiving (read:, awake and finishUnarchiving).  One possible workaround is to delay the isTestingInterface message by calling perform:with:afterDelay:cancelPrevious:.  Another workaround you can consider is illustrated in Jeff Martin's StringList MiniExample.  You can take a look at the StringList MiniExample available via NeXTAnswers, document #1254.  The workaround is implemented in the awake method for FilenameList.  It is only valid in awake:
  15.  
  16.     // test to see if mainMenu is visible, which it isn't while test
  17.     // interface mode is being set up. 
  18.  
  19.     if([NXApp conformsTo:@protocol(IB)]) 
  20.         if([[NXApp mainMenu] isVisible]) {
  21.             // do something special for test mode
  22.             return self;
  23.         }
  24.  
  25.  
  26. QAxx
  27.  
  28. Valid for 3.0, 3.1