问题标签 [nsstatusbar]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2479 浏览

objective-c - OSX 状态栏图像大小调整 - Cocoa

因此,我对某个项目的图像有疑问,就像您在这张图片中看到的NSStatusBar那样,该图像似乎正在远离其余的菜单项。但是,当菜单栏处于非活动状态时(如我在我的另一台显示器上或不在应用程序中),问题不会发生,正如您在这张图片中看到的那样。我很确定我的代码是正确的。

我查看了这个问题:在可可状态应用程序中显示图像但问题仍然存在,所以我不确定还能做什么,感谢您的帮助!PS:我认为的问题是NSVariableStatusItemLength,我试过NSSquareStatusItemLength但没有运气,也尝试过自己设置,但同样的问题,但几乎没有改善。

0 投票
1 回答
181 浏览

objective-c - 如何动态地将 NSView 与 NSStatusBar 相关联?

我创建了一个像这样的 NSStatusBar NSMenu:

我想动态移动[self startUpView]指向图标所在位置的 NSView ()。类似于 Evernote 的做法。如您所见,它是图标的中心:在此处输入图像描述

而我的 NSStatusBar NSView 落在 NSStatusBar 图标的左侧或右侧。

所以两个问题:

如何移动下拉 NSView?

我尝试更改框架(-100),但没有区别:

如何动态移动与图标相关的下拉 NSView?

0 投票
3 回答
4683 浏览

swift - NSMenuItem 中的 Swift 2.2 选择器

我在 swift 中有一个简单的文件菜单栏应用程序:

我无法将“关于”菜单栏项连接到 about() 函数。当我运行应用程序时,“关于”项被禁用。

如何在 Swift 2.2 中将选择器传递给菜单项操作?谢谢

0 投票
2 回答
296 浏览

ios - 隐藏 iOS 状态栏的文本

这个问题不是关于隐藏状态栏,而只是隐藏状态栏的文本

我无法在任何地方找到它来解决这个问题

UBER 应用是这样做的,当我们在 uber 中打开侧边菜单时,状态栏文字消失,

0 投票
1 回答
1688 浏览

swift - Redirect button action to another function in Swift

This might be an easy question, but I am new to Swift and do not know for which terms to google for.

For a menu bar application, I have implemented a custom function called doSomething that works just fine when it is bound to some button:

However, I need to distinguish between left- and right click on the button, which in my case is a NSStatusBarButton. Following the suggestion from this answer, I have written the following into my AppDelegate.swift:

The above code snippet gives me the error message 'Expression resolves to an unused function' in XCode. I cannot figure out how to properly call the function doSomething from the MainViewController class within the customClickAction function, or equivalently, how to redirect the action of the statusItem.button via customClickAction to doSomething. I apologize if this question might seem too trivial for the Swift experts, but I am really in despair trying to figure this one out.

EDIT:

If the function customClickAction was not existing, I would simply write button.action = #selector(mainViewController?.show(_:)) in applicationDidFinishLaunching to call the function and everything works. However, part of my problem is that doing the same in my custom function would overwrite the binding once the left mouse button has been pressed for the first time.

0 投票
2 回答
2835 浏览

swift - 检测 NSStatusItem (Swift) 上的左右单击事件

我正在构建一个状态栏应用程序,并希望根据用户是单击左键还是单击右键来调用不同的操作。这是我到目前为止所拥有的:

我的函数没有被调用,我找不到我们的原因。我很感激任何帮助!

0 投票
1 回答
158 浏览

objective-c - NSMenuBar 应用程序影响(禁用)彼此的视图(NSMenuItem 的)?漏洞

我正在开发一个 NSMenuBar 应用程序,而另一个 NSMenuBar 应用程序似乎影响了我的应用程序的显示行为!?更准确地说:Adobe 的 Creative Cloud 应用程序。当我单击那个(创意云)图标时,会出现弹出视图。之后,当我点击我的状态栏图标时,我的菜单出现了,但是,所有应该启用的 NSMenuItem 突然被禁用,不再交互。

一些观察:

当我记录 NSMenuItem 的启用状态时,它会正确记录为已启用,但它显然没有显示为已启用(参见屏幕截图),单击它只会关闭菜单而不执行相关操作。我使用以下代码进行日志记录:

我使用的 NSMenu 设置为 setAutoenablesItems:NO。

此外,Adobe 的 Creative Cloud 使用弹出视图。当它打开时,它清楚地悬停在我的 NSMenu 正在使用的屏幕空间上。

当我尝试使用其他 NSMenuBar 应用程序(例如 Apple 的 Wifi 或蓝牙)重现这一点时,一切正常。没问题。再说一次,这些应用程序不使用 Popover-views,它们并没有完全重叠我的应用程序的空间。

请参阅这些屏幕截图作为说明:

在此处输入图像描述

恶意创意云

在此处输入图像描述

在此处输入图像描述

我在这里想念什么?应用程序不应该像这样相互影响吗?我正在慢慢地但肯定会为此失去理智。非常感谢任何帮助!谢谢!!

0 投票
1 回答
447 浏览

objective-c - NSMenu 委托不触发 menuWillOpen

我有一个 Interface Builder NSMenu-Object。我添加了我的自定义类“StatusBarMenu”。

StatusBarMenu.h文件如下所示:

StatusBarMenu.c文件如下所示:

菜单分配AppDelegate.c如下:

AppDelegate.h

菜单打开,但没有调用 menuWillOpen。我错过了什么吗?

我很感激任何帮助!谢谢。

0 投票
1 回答
1475 浏览

swift - MacOS状态栏应用程序显示菜单并使用swift 3单击运行功能

我正在使用 Swift 3 制作一个小型菜单栏应用程序,我希望应用程序在单击图标时重新加载一些数据,但我也希望它显示 statusMenu?

以下是我的代码示例:

如果我注释掉

doSomething() 函数将运行,但我不知道如何同时显示菜单和运行 doSomething 函数,我该怎么做?

0 投票
1 回答
802 浏览

swift - NSStatusBar 中的 NSStatusItem,动作选择器方法没有响应

首先我声明状态项:

然后我有一个关闭寡妇并添加状态项的功能:

这是我的操作选择器方法,它应该删除状态项并再次显示窗口。按下状态栏中的状态栏项目时不会调用它:

有人知道我做错了什么吗?