This is what I got so far.
- (IBAction)HUDPanelDictionaryHide:(id)sender{
extern NSPanel HUDPanelDictionary;
[HUDPanelDictionary close];
}
This obviously does NOT work.
The HUDPanelDictionary is declared in a separate .h and .m file for an .xib file. I need to close this panel from the other .h and .m file for another .xib file. Sorry I’m being so vague!
Any ideas??
Elijah
You need to
#importthe header containing the declaration of HUDPanelDictionary.For example:
I would also name things differently, for example “DictionaryHUD” rather than “HUDPanelDictionary.” “Panel” is redundant with “HUD,” and you should care more about its intent than its position in the class hierarchy.
Another thing I would do is make DictionaryHUD an NSWindowController subclass, and have it expose a singleton shared instance rather than use a global variable to point to the panel itself. Then the code above would look like this:
This puts the primary responsibility for your dictionary panel/HUD on an instance of a single controller class, to which other controllers (say one that manages your main window’s toolbar) can forward their interactions. You could even put the dictionary HUD window controller in the responder chain to have it automatically handle actions like
-hideDictionaryPanel:so nothing needs to do that kind of forwarding.