问题标签 [menuitem]

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 回答
186 浏览

wpf - Databinding to functions in dynamically-loaded plugins

I have several MenuItems whose Commands are bound to my ViewModel. Until today, all of them execute properly.

Now I have added a MenuItem whose ItemsSource is bound to an ObservableCollection. The point of this MenuItem is to enumerate a list of plugins so that the name of all plugins show up. Then when the user clicks on a plugin name, it should call a function to display properties for audio filters.

In my current implementation, which doesn't work, I tried to databind like this:

The problem is that I get a BindingExpression path error because it's trying to use a String as the MenuItem's DataContext.

This leads me to believe that the DataContext for a MenuItem's MenuItems is automatically set to type of objects in the ItemsSource. Is this true?

If I need to change the DataContext, then I'd like to change it to the ViewModel that handles all of my other Commands. But if I do that, how in the world am I able to tell which plugin I want to display filter properties for? I'd need to pass in a CommandParameter at the very least, but binding this value to the filter name isn't my most favorite option. Are there any other ways to do this?

If the DataContext is indeed automatically set to the object type in the ObservableCollection, then I'd rather just call my interface method ShowFilterProperties() directly. I bet that I can't do this without Command binding. If that is the case, how do you all deal with this sort of application? Do you make all of the plugins expose a command handler, which will then show the dialog?

EDIT -- I modified my code to change the ObservableCollection type, and sure enough, WPF wants to databind to the type T. So I guess one option is to have the plugin expose the ICommand, but I don't know if this is a weird approach or not?

EDIT -- ok, I just learned something new. Interfaces can't have fields, so is it not possible to databind with plugins, period?

0 投票
6 回答
5059 浏览

php - Drupal 6 动态菜单项

我需要创建一个菜单项,如果用户有特定条件,它会更改其标题和链接。Drupal 缓存了所有的菜单,所以我真的想不出办法来做到这一点。

例如,用户有一个节点附加到他的配置文件,菜单项是“创建 blabla”(链接节点/添加/blabla)用户没有节点,菜单项是“创建 notblablabla”(链接节点/添加/notblabla)

0 投票
1 回答
2189 浏览

c# - 尽管 MSDN 说了什么,禁用顶级菜单项并不会禁用子项?

根据http://msdn.microsoft.com/en-us/library/aa984351%28VS.71%29.aspx

禁用菜单中的第一个或顶级菜单项(例如,传统文件菜单中的“文件”菜单项)会禁用菜单中包含的所有菜单项。同样,禁用具有子菜单项的菜单项会禁用子菜单项。

根据http://msdn.microsoft.com/en-us/library/ms171655.aspx

禁用菜单中的第一个或顶级菜单项会禁用菜单中包含的所有菜单项。同样,禁用具有子菜单项的菜单项会禁用子菜单项。

但是,如果我创建一个新的 Windows 窗体项目并添加以下代码,我仍然可以使用快捷键访问Child根据 MSDN应该禁用的菜单项。

我可以看到这childMenuItem.Enabled根本没有改变,而topLevelMenuItem.Enabled确实如此。

当然,我可以使用 for 循环来禁用菜单下的所有菜单项Top Level,甚至只禁用Child菜单项,但根据 MSDN,我不应该这样做。这是怎么回事?我是否遗漏了某些东西,误解了某些东西,还是 MSDN 错了?

0 投票
1 回答
447 浏览

java - 覆盖 Java/Swing 中 JMenuItems 中加速键的显示外观

我注意到在某些 Mac 上,JMenuItem 使用“空格”一词来表示空格键是键绑定。在其他 mac 上,使用了一个符号(看起来像一个短大写 U)。我更喜欢“空间”演示,因为它对用户更透明。有没有办法覆盖 LAF 以图形方式表示加速键的方式?

0 投票
1 回答
998 浏览

wpf - 如何将 MenuItem 集合直接数据绑定到 XAML

我有一个包含列表框的用户控件。ListBox 使用另一个 UserControl 作为 DataTemplate。

在后面的代码中,我将数据上下文设置为 ObservableCollection。ExpanderItem 公开了以下公共属性... string Name、ObservableCollection MenuItems、bool Expanded、UserControl Control 我已经为这些属性实现了 INotifyPropertyChanged 接口。

我的 ExpanderDataTemplate 看起来像这样......

在这里,您可以看到我将数据绑定到所有四个属性 Expanded、Control、Name 和 MenuItems。所有属性都得到正确的界限和可见的期望 MenuItems。MenuItems 是 System.Windows.Controls.MenuItem 的 ObservableCollection。

我想在单击 DropDownMenuItem 时实现所需的行为,我应该将数据有界的 MenuItems 集合视为子菜单。

请帮助我。谢谢你。

0 投票
4 回答
4373 浏览

php - 如何将 joomla 菜单项类型的结果显示为模块?

我不知道该怎么说...但是我在我的 joomla 站点中使用某些模块,这些模块只能使用菜单项显示,例如 Phoca 画廊、hwdvideoshare 等。这些模块不能显示在任何特定位置,而是必须创建链接到这些模块并根据所选配置参数显示它们的菜单项。我是否可以在任何文章中使用这些菜单项点击的结果?例如,我想将特定类别的视频库显示为一个模块(不创建任何要单击的菜单项)?

如果我不清楚我的要求是否被理解,请提出问题,我会回复,因为我不确定我应该如何解释我的要求以及我应该搜索什么。

0 投票
8 回答
7683 浏览

delphi - Delphi 菜单项和工具栏按钮的无版权资源图像集

每次我需要创建带有操作的菜单或工具栏时,我最终都会收集一些从不同应用程序中提取的图像,并使用图像编辑器手动调整它们。这既耗时又无聊(尽管我承认在某些情况下这可能是一个令人耳目一新的休息)。

你知道这些图像的任何集合吗?我希望菜单模板中的所有菜单项至少有图像。它们必须是无版权的。谢谢。

0 投票
1 回答
460 浏览

wpf - 如何从 menuitem 中找到选定的项目

我有一个ContextMenu在运行时绑定了一些项目MenuItem。我也订阅了一个Click活动。

现在如何从事件中的绑定项目中找到哪个项目被点击了?

谢谢,

0 投票
2 回答
5144 浏览

java - JSF 添加动作监听器

我正在动态创建一个 MenuItem,并且我想在单击 MenuItem 时添加一个自定义侦听器。

我已经尝试添加 addActionListener 和 setActionListener ,但是当点击链接时这些都不会被调用。

似乎有一个名为“listeners”的列表附加到 MenuItem(我可以在使用侦听器静态调试 MenuItem 设置时看到这一点)。知道如何正确添加侦听器吗?

0 投票
3 回答
8053 浏览

c# - 菜单项打开和关闭事件

每当菜单项的子菜单打开时,我想处理一个事件。关闭也一样。我怎样才能做到这一点?