问题标签 [contextmenu]
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.
wpf - 系统托盘上下文菜单 - 为什么我的命令未启用?
我正在创建一个 WPF 应用程序,并有一个带有上下文菜单的系统托盘图标。对于我想使用 WPF 命令的菜单项,但是当我分配它们时,即使在其他地方启用了(相同的)命令,它们也总是灰色的。
当我分配单击事件并且我尝试为始终将 CanExecute 设置为 true 的命令创建 CanExecute 方法时,它工作正常,但这也无济于事。任何人都知道为什么菜单项被禁用?
更新:按照建议,我在上下文菜单中添加了一个命令绑定。这样做的效果是,它只有在您单击菜单后才能起作用,即,起初菜单项是灰色的,但是一旦您单击菜单上的某个位置,选项就会启用。
为了解决这个问题,在将菜单项添加到上下文菜单后,我调用了以下方法:
javascript - 如何在 JavaScript 中禁用右键单击上下文菜单
并不是说我试图阻止“查看源代码”或类似的愚蠢行为,而是我正在为某些元素制作一些自定义上下文菜单。
编辑:对答案的回应:我试过这个:
java - Eclipse RCP and JFace: Problems with Images in Context menu and TreeViewer
I'm working on an Eclipse RCP application. Today I experienced some troubles when displaying images in the context menu. What I wanted to do is to add a column to my table containing images of stars for representing a user rating. On Windows, this causes some problems, since the star images are squeezed up on the left corner of the table cell instead of expanding on the whole cell, but I'll solve that somehow. In addition I have a context menu on the table, with an entry called "rate" where again the different stars from 1 to 5 (representing the rating level) are shown, such that the user can click on it for choosing different ratings. That works fine on Windows. Now I switched to Linux (Ubuntu) to see how it works out there, and strangely, the stars in the table cell are layed out perfectly, while the stars on the context menu don't even show up. Rating inside the table cell works http://img187.imageshack.us/img187/4427/starsratingho4.png
star images don't show up http://img514.imageshack.us/img514/8673/contextmenuproblemgt1.png
On the context menu I'm using an action class where I'm setting the image descriptor for the star images:
}
Does somebody know why this strange behaviour appears?
Thanks a lot.
(For some strange reason, the images don't appear. Here are the direct URLs: http://img187.imageshack.us/img187/4427/starsratingho4.png http://img514.imageshack.us/img514/8673/contextmenuproblemgt1.png)
//Edit: I did some tries and it seems as if the images just don't appear when using a Checkbox style for the context menu (see constructor of the RateAction). When I switched to a PushButton style, the images appeared, although not correctly scaled, but at least they were shown.
python - 在 Python 中接受文件参数(从发送到上下文菜单)
我将首先指出我几乎没有 python 经验。
替代文字 http://www.aquate.us/u/9986423875612301299.jpg
您可能知道,只需在 Windows PC 上的“发送到”文件夹中放置一个快捷方式,您就可以允许程序将文件作为参数。
我将如何编写一个将此文件作为参数的python程序?
而且,如果有人有机会,作为奖励——我如何将它与 urllib2 集成以将文件发布到我服务器上的 PHP 脚本?
提前致谢。
编辑——另外,我如何在 Sendto 菜单中显示一些东西?我的印象是,您只需将快捷方式放入 SendTo 文件夹,它就会自动在菜单中添加一个选项……没关系。我发现我做错了什么:)
.net - 创建自定义上下文菜单
我有一个简单的对话框,我想将其显示为上下文菜单。
我可以点击右键并将其显示为没有边框的模态对话框,如果可能的话,我希望它看起来像 Windows 上下文菜单(lhs 上的栏,蓝色边框) - 有没有办法自动收集用户桌面设置,(需要同时适用于 XP、Vista)?
c# - 如何从 C# 应用程序显示 Windows 资源管理器上下文菜单?
我的应用程序中有一个文件列表,我希望允许人们右键单击一个项目并显示 Windows 资源管理器上下文菜单。我假设我需要使用 IContextMenu 接口,但我不确定从哪里开始。
wpf - 从 ContextMenu 命令中找到 TabItem 的正确方法
我有我在其上设置 ContextMenu 的 TabControl。
所有 ContextMenu 元素都有命令集。
所有命令都被路由,并且 CommandBindings 在 TabControl 之上定义了几个级别。
所以问题是:在 CommandBinding CanExecute/Execute 事件处理程序中,找出调用菜单的 TabItem 的正确方法是什么?正确的意思是,如果我更改 TabItem 模板之类的东西,它就不会损坏。
或者可能整个方法是错误的,我不应该为此使用路由命令?我最初将路由用于需要热键的“添加新选项卡”命令。
提前致谢。
更新:
Igor 的解决方案比架构 POV 更清晰(除了我会在 ViewModel 中删除 _),但我希望有一个独立于 TabControl 绑定的可重用关闭命令(因为所有类型的应用程序中都存在选项卡的关闭/关闭全部)并且没有在语义上链接到特定模型)。
此外,我不能使用自定义 DataTemplate,因为我已经有一个自定义模板,并且子类化它会使解决方案有点过于复杂。
c# - TabControl 上下文菜单
在 Windows 窗体应用程序中,我在 TabControl 上设置了 ContextMenuStrip 属性。
- 如何告诉用户单击了当前选择的选项卡以外的选项卡?
- 如何限制上下文菜单仅在单击带有标签的顶部选项卡部分时才显示,而不是在选项卡的其他位置显示?
java - Java JTree的右键单击上下文菜单?
我正在尝试在 Java JTree 中实现弹出菜单。我将 DefaultTreeCellRenderer (以更改节点外观)和 DefaultTreeCellEditor (以创建组件以将事件侦听器附加到,因为显然 DefaultTreeCellRenderer.getTreeCellRendererComponent() 返回的组件不能做到这一点?)。我真的不想“编辑”节点,只是能够在节点被右键单击时弹出一个菜单,但这是我现在能想到的唯一方法......
下面是我到目前为止的代码——我只是想弄清楚如何捕获 MouseEvents。它有点工作,但很糟糕。有什么更好的方法来完成我在这里尝试做的事情?
wpf - WPF DataGrid 上下文菜单
如何为 DataGrid(Microsoft 的网格)中的每一列定义不同的 ContextMenus?我发现网格提供了一个ContextMenu
属性,但我想要列的不同上下文菜单项,而不是整个网格的相同 ContextMenu。
编辑:感谢您的回答!我试着听ContextMenuOpeningEvent
你的建议,这是第一次成功:可以在 EventHandler 中修改 ContextMenu。但它引发了另一个(希望很小)问题 - 我现在必须识别ContextMenuOpeningEvent
触发时鼠标光标所在的列。稍后我将研究如何做(或解决)这个问题。