NSMenu 显示/隐藏 HUD NSPanel 的问题
对于这个问题仍然有很大的困难。有什么建议吗?
我无法在网上找到一个简单的教程来解释 NSPanel 窗口与 NSWindow 不同的基础知识。
我有一个 HUD 窗口,我想将其显示为通知和消息输入框,但我无法弄清楚如何进行。我的尝试如下。
我知道这是一个措辞不当且过于宽泛的问题;作为 Objective C 和 Interface Builder 的新手,我还没有足够的经验来进行更具体的说明。
在相关部分:AppController.h
@interface AppController : NSObject {
IBOutlet NSMenu *statusMenu;
IBOutlet id HUDPanel;
IBOutlet NSTextField *HUDTextField;
IBOutlet NSTextField *HUDLabel;
IBOutlet NSProgressIndicator *HUDSpinner;
NSStatusItem *statusItem;
NSImage *statusImage;
NSImage *statusHighlightImage;
}
- (IBAction)recognizeCurrentLocation:(id)sender;
- (IBAction)saveButtonPressed:(id)sender;
- (IBAction)newLocationMenuItem:(id)sender;
- (IBAction)HUDPanelHide:(id)sender;
- (IBAction)HUDPanelShow:(id)sender;
@end
在相关部分:AppController.c
- (IBAction)HUDPanelHide:(id)sender{
[HUDPanel close];
}
- (IBAction)HUDPanelShow:(id)sender{
[HUDPanel makeKeyAndOrderFront:self];
}
我相当确定我在 IB 中的链接是正确的 - 我按照教程设置了大部分内容,并且我分配给其他操作的菜单项是正确的执行。
我找到的教程在这里:
http://www.mataderu.com/xphere /info/cocoa_tut02/OpenGLrules.zip
Still having great difficulty with this problem. Any suggestions?
I cannot find a simple tutorial online that explains the basics of NSPanel windowing as different from NSWindow.
I have an HUD window that I'd like to show as a notification & input box, but I cannot for the life of me figure out how. My attempts are below.
I know this is a poorly phrased and overly broad question; being new to Objective C and Interface Builder, I do not quite yet have my feet wet enough to be more specific.
In relevant part: AppController.h
@interface AppController : NSObject {
IBOutlet NSMenu *statusMenu;
IBOutlet id HUDPanel;
IBOutlet NSTextField *HUDTextField;
IBOutlet NSTextField *HUDLabel;
IBOutlet NSProgressIndicator *HUDSpinner;
NSStatusItem *statusItem;
NSImage *statusImage;
NSImage *statusHighlightImage;
}
- (IBAction)recognizeCurrentLocation:(id)sender;
- (IBAction)saveButtonPressed:(id)sender;
- (IBAction)newLocationMenuItem:(id)sender;
- (IBAction)HUDPanelHide:(id)sender;
- (IBAction)HUDPanelShow:(id)sender;
@end
In relevant part: AppController.c
- (IBAction)HUDPanelHide:(id)sender{
[HUDPanel close];
}
- (IBAction)HUDPanelShow:(id)sender{
[HUDPanel makeKeyAndOrderFront:self];
}
And I am fairly sure that my linking in IB is correct - I followed a tutorial to set most of this up, and menu items that I have assigned to other actions are properly executing.
The tutorial I found was here:
http://www.mataderu.com/xphere/info/cocoa_tut02/OpenGLrules.zip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然我的答案是我没有创建“实用程序窗口” - 例如我有一个 *.xib 而不是 *.nib 文件。
我不确定为什么这会产生影响,所以也许专家的更多解释在这里值得注意。
否则,我的代码正是它应该的样子。
Apparently my answer was that I was not creating a "utility window" - e.g. I had an *.xib instead of a *.nib file.
I'm not sure why this makes a difference so perhaps more explanation from an expert would be worth noting here.
Otherwise, my code was exactly what it should be.