标签: contextmenu

VB.NET如何使1个子项适用于多个项目?

我有一个冗长的上下文菜单,我想为这些项添加一些视觉效果(不,我不想创建一个新的渲染器),所以我只为其中一个列表项创建了一个MouseEnter和MouseLeave事件.现在我想将其扩展到所有上下文菜单项,而不为每个项目制作两个单独的事件......

这是我目前所拥有的一个简短例子:

Private Sub NewMenuItems_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewMenuItem1.MouseEnter, NewMenuItem2.MouseEnter, etc.
    MenuItem.ForeColor = Color.Red
End Sub

Private Sub NewMenuItems_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewMenuItem1.MouseLeave, NewMenuItem2.MouseLeave
    MenuItem.ForeColor = Color.Cyan
End Sub
Run Code Online (Sandbox Code Playgroud)

每个项目唯一不同的是".Forecolor"之前的内容.如何同时为所有项目进行此项工作?

vb.net vb6 contextmenu

2
推荐指数
1
解决办法
254
查看次数

防止右键单击动态添加的图像

我想禁用任何图像的右键单击.

这工作正常,但仅适用于静态图像.

$('img').bind('contextmenu', function(
    return false;
});
Run Code Online (Sandbox Code Playgroud)

如何防止右键单击动态添加的图像?

jquery contextmenu image right-click

2
推荐指数
1
解决办法
258
查看次数

用于"MenuItem"类型的样式不能应用于"分隔符"类型

我正在使用WPF Window Application ContextMenu.

ContextMenu的XAML(在Window.Resources中):

<ContextMenu x:Key="menuList" Placement="Bottom" >
    <ContextMenu.ItemContainerStyle>
        <Style TargetType="{x:Type MenuItem}">
            <Setter Property="Header" Value="{Binding Name}"/>
            <EventSetter Event="Click" Handler="cm_RefreshChannelNotification"/>
            <Setter Property="IsChecked" Value="{Binding CFiltered}" />
            <Setter Property="IsCheckable" Value="True"/>
            <Setter Property="StaysOpenOnClick" Value="True"/>           
        </Style>
    </ContextMenu.ItemContainerStyle> 
</ContextMenu> 
Run Code Online (Sandbox Code Playgroud)

当我尝试将Separator添加到ContextMenuI收到错误时:

System.InvalidOperationException未处理Message ="用于'MenuItem'类型的样式不能应用于'分隔符'类型.

这样我必须添加一个新的分隔符:

ContextMenu cm = this.FindResource("menuList") as ContextMenu;
Separator separator = new Separator();
separator.SnapsToDevicePixels = true;  
cm.Items.Add(separator);
Run Code Online (Sandbox Code Playgroud)

我应该在ContextMenu定义中更改/添加什么才能使其正常工作?

c# wpf contextmenu menuitem separator

2
推荐指数
1
解决办法
2362
查看次数

WPF重写ContextMenu样式 - DropShadowEffect不起作用

我想要覆盖它ContextMenu的风格.
这是我的风格:

<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#E7E8EC" />
<SolidColorBrush x:Key="SolidBorderBrush" Color="#CCCEDB" />
<Color x:Key="DropShadowColor">#808080</Color>

<Style TargetType="{x:Type ContextMenu}">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="FontFamily" Value="Segoe UI"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ContextMenu}">
                <Border Name="Border" Background="{StaticResource WindowBackgroundBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1" >
                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    <Border.Effect>
                        <DropShadowEffect Color="{StaticResource DropShadowColor}" Opacity="0.60" ShadowDepth="4"/>
                    </Border.Effect>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

我不知道为什么,但阴影不起作用(我看不到阴影).
我该如何解决?

wpf xaml styles contextmenu

2
推荐指数
1
解决办法
2172
查看次数

带有CheckBox和ContextMenu的JavaFx TreeView

在教程http://docs.oracle.com/javafx/2/ui_controls/tree-view.htm中,它解释了如何使用ContextMenu或CheckBox创建TreeView.

但有可能同时拥有它们吗?

当我第一次复制粘贴代码时,我了解到我只能有一个setCellFactory,因为它们会相互覆盖.

    // the following two setCellFactory are copied from the tutorial

    // this create TreeCell with ContextMenu
    treeView.setCellFactory(new Callback<TreeView<String>,TreeCell<String>>(){
        @Override
        public TreeCell<String> call(TreeView<String> p) {
            return new TextFieldTreeCellImpl();
            //the class TextFieldTreeCellImp is a TreeCell with ContextMenu
        }
    });

    // this create TreeCell with CheckBox
    tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
Run Code Online (Sandbox Code Playgroud)

然后我尝试用CheckBoxTreeCell替换TreeCell

    //class TextFieldTreeCellImpl extends TreeCell<String> {
    class TextFieldTreeCellImpl extends CheckBoxTreeCell<String> {
    ...
    //TreeItem newTag = new TreeItem<String>("New tag");
    CheckBoxTreeItem newTag = new CheckBoxTreeItem<String>("New tag");
Run Code Online (Sandbox Code Playgroud)

但是没有出现复选框.它仍然是一个正常的树视图.

checkbox treeview javafx contextmenu

2
推荐指数
1
解决办法
1110
查看次数

AngularJs使用SubMenu创建上下文菜单

我想用angularjs在指令中创建一个上下文菜单,我可以创建一个菜单但不能用子菜单创建.我的意思是,在悬停时打开子菜单.

示例小提琴:示例上下文菜单

我的控制器:

$scope.menuOptions = [
        ['New User', function () {
           console.log("New User");
        }],
        ['Delete', function () {
           console.log("Delete");
        }]
    ]; 
Run Code Online (Sandbox Code Playgroud)

这个小提琴是非常好的,只有我想在这个上下文菜单中添加子菜单.如何根据此示例创建子菜单?

javascript model-view-controller contextmenu dynamically-generated angularjs

2
推荐指数
1
解决办法
3570
查看次数

在PyQt4中向listwidget添加右键单击功能

我试图使用Python为PyQt4中的列表小部件中的项添加右键单击功能.我想像一个弹出的上下文菜单,显示有按钮,点击时应该执行一些功能.

如何在右键单击每个项目时弹出上下文菜单?

python contextmenu qlistwidget pyqt4

2
推荐指数
1
解决办法
4075
查看次数

在Finder上下文中建立服务

我正在尝试使用此类向Finder的上下文菜单添加服务:

public class Service {
  public func handleServices(pboard:NSPasteboard, userData:String, error:UnsafeMutableBufferPointer<String>) {  // not sure about the correct parameters
    if (pboard.types?.contains(NSFilenamesPboardType) != nil) {
      let fileArray = pboard.propertyListForType(NSFilenamesPboardType)
      print(fileArray)
    }
  }

  init () {
    NSApp.servicesProvider = self
    NSUpdateDynamicServices()
  }
}
Run Code Online (Sandbox Code Playgroud)

该服务在info.plist中公布如下:

<key>NSServices</key>
<array>
    <dict>
        <key>NSMenuItem</key>
        <dict>
            <key>default</key>
            <string>Service Handling Demo</string>
        </dict>
        <key>NSMessage</key>
        <string>handleServices</string>
        <key>NSPortName</key>
        <string>services</string>
        <key>NSSendTypes</key>
        <array>
            <string>NSFilenamesPboardType</string>
        </array>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)

最后,我在系统偏好设置/键盘/快捷方式中打开了该服务.所以我看到了服务并且可以调用它.但是我在打电话时得到的只是

找不到选择器handleServices的服务提供者:userData:error:或handleServices :: for service handleServices

service finder contextmenu swift

2
推荐指数
1
解决办法
800
查看次数

如何根据条件动态更改上下文菜单中的名称

我正在为jQuery使用此contextmenu插件:

http://swisnl.github.io/jQuery-contextMenu/demo/trigger-left-click.html

我试图通过一个简单的条件动态地更改菜单项的名称。不幸的是,无法动态更改菜单项的名称,或者我不知道该如何更改...

我这样尝试过:

   items: {
           "item": {name: (x > 10) ? 'name1' : 'name2', disabled: false},
           "sep1": "----------------",
           ....
   }
Run Code Online (Sandbox Code Playgroud)

但它不起作用。然后我尝试使用匿名函数:

 items: {
         "item": {name: function(){ return (x > 10) ? 'name1' : 'name2'; }, disabled: false},
         "sep1": "----------------",
         ....
 }
Run Code Online (Sandbox Code Playgroud)

但是效果不佳...现在我没有其他线索了,所以我要向您寻求帮助。您对我有有用的建议吗?任何帮助表示赞赏。

提前致谢。

jquery contextmenu

2
推荐指数
1
解决办法
3941
查看次数

获取单击了上下文菜单项的Extjs网格

我有一个网格,并且在网格上下文菜单上,我正在调用一个函数,如下所示:

在网格上下文菜单中,我添加了以下项目

{ text: 'Preview', handler: 'PreviewGrid', scope: cnt, };
Run Code Online (Sandbox Code Playgroud)

在控制器中

previewGrid: function (contextMenuItem) {    
        // Here I am getting the item i.e. contextmenu item.
        // But I want here is grid on which there was right click
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用 item.ownerCt.up('grid')

但它不起作用。

任何帮助将不胜感激。

javascript grid extjs contextmenu extjs6

2
推荐指数
1
解决办法
2665
查看次数