我像这样创建弹出菜单。
<DockPanel.ContextMenu>
<ContextMenu Background="#CD252220" Opacity="0.95" Foreground="LightGray" BorderBrush="DarkGray">
<MenuItem Header="_Save Image..." x:Name="btSave" IsEnabled="False" Click="btSave_Click" Style="{StaticResource MyStyle}">
<MenuItem.Icon>
<Image Source="icons/save.png" Width="16" Height="16" Style="{StaticResource IconStyle}"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</DockPanel.ContextMenu>
Run Code Online (Sandbox Code Playgroud)
为什么这个菜单的左侧是白色的???它将是#CD252220 颜色或透明,发髻不是白色!!!!!!如何修复它?:)
http://itrash.ru/idb/40e872e71346dcf9bd58ba8aec0b2a17/omenu.png.html - 菜单截图
PS XP下没问题。菜单仅在 Vista 上为白色(没有 W7)
奇怪的是,Fragment 和 v4.Fragment 都没有实现“onContextMenuClosed”。还有其他事件,例如 onCreateContextMenu 和 onContextItemSelected。
当上下文菜单关闭时,我需要清理一些东西,可以通过后退按钮激活,点击屏幕上的空白区域,或者选择上下文菜单中的一个菜单项。
那么如何监控片段中上下文菜单的消失呢?
我在 TreeView 中有一个上下文菜单
UserControl (DataContext=ViewModel)
|
|
---- TreeView (ItemSource=MyItems)
|
|
----- Items (ItemSource=MyChildrenItems)
|
|
----- ContextMenu
Run Code Online (Sandbox Code Playgroud)
我想将 ContextMenuItem 的命令绑定到 ViewModel 中的 RelayCommand,我尝试了各种relativesource 绑定,但似乎没有任何效果...
我应该如何配置RelativeSource 绑定?
<ContextMenu>
<MenuItem
Header="Bla"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TreeView}, Path=DataContext.MyRelayCommand}" />
Run Code Online (Sandbox Code Playgroud)
我收到类似的绑定错误
无法找到引用“RelativeSource FindAncestor,AncestorType='System.Windows.Controls.TreeView',AncestorLevel='1”的绑定源。BindingExpression:Path=DataContext.ExcludeSeasonCommand; 数据项=空;目标元素是“MenuItem”(名称=“”);目标属性是“Command”(类型“ICommand”)
在 Cocoa 应用程序中,是否有一种方法可以让用户在按住 Option (?) 键时轻松地在上下文菜单中显示其他或完全不同的选项?
这是在全局菜单栏中的 Volume 上下文菜单中使用的:


它也在 Finder 中使用,但我无法截取屏幕截图,因为截取屏幕截图的快捷方式取消了 Option (?) 上下文菜单。
I know this question has been asked many times but it seems no better solution for it.
Changing the allowsUserCustomization property doesn't help. It seems there is no API to customize the items in toolbar's context menu.
Finder app has no "Use Small Size" while Notes app has only "Customize Toolbar.."
I would like to know if there is any way to subclass or extend or do whatever to the NSToolbar to achieve the purpose?
Updated 1:
According to @Khundragpan …
我有一个BrowserView内部BrowserWindow(我确实需要两者):
const { app, BrowserWindow, BrowserView } = require('electron');
app.on('ready', () => {
browserWindow = new BrowserWindow({ width: 800, height: 500, frame: false });
bv = new BrowserView({ webPreferences: { nodeIntegration: false }});
bv.setBounds({ x: 0, y: 30, width: 800, height: 470});
bv.webContents.loadURL('https://old.reddit.com');
browserWindow.setBrowserView(bv);
});
Run Code Online (Sandbox Code Playgroud)
在网页上单击鼠标右键没有任何作用。如何像往常一样使用 Chrome 启用右键单击以具有“后退”、“前进”、“重新加载”、“复制”、“粘贴”等功能?
在我的应用程序中,我有一个包含两个项目的 ContextMenuStrip。每个项目都有一个图像和一个文本。如下图所示,菜单项的图像部分与其文本之间存在默认间隙(该间隙由红色箭头指示)。
我想通过向左移动文本来减少水平间隙,以便将间隙减少到最大 1 像素。
是否可以?如果是,我该怎么办?
在 iOS 中,可以通过长按或点击来显示上下文菜单。目前,以下代码在长按时显示上下文菜单,如何在轻按时显示菜单?
let interaction = UIContextMenuInteraction(delegate: self)
tagBtn.addInteraction(interaction)
func contextMenuInteraction(_ interaction: UIContextMenuInteraction,
configurationForMenuAtLocation location: CGPoint)
-> UIContextMenuConfiguration? {
let favorite = UIAction(title: "Favorite",
image: UIImage(systemName: "heart.fill")) { _ in
// Perform action
}
let share = UIAction(title: "Share",
image: UIImage(systemName: "square.and.arrow.up.fill")) { action in
// Perform action
}
let delete = UIAction(title: "Delete",
image: UIImage(systemName: "trash.fill"),
attributes: [.destructive]) { action in
// Perform action
}
return UIContextMenuConfiguration(identifier: nil,
previewProvider: nil) { _ in
UIMenu(title: "Actions", children: [favorite, share, delete]) …Run Code Online (Sandbox Code Playgroud) 我创建了一个具有树结构的上下文菜单(添加了菜单项,然后在这些菜单项中添加了复选框作为子菜单项)。这在手动添加/删除项目方面工作得很好。但是,当涉及到以编程方式重置项目时,一般组件与特定组件(在本例中为复选框)之间存在冲突。
Component comp = contextMenu.getItems().get(x).getSubMenu().getItems().get(y);
if (comp instanceof Checkbox) {
((Checkbox) comp).setValue(false);
}
Run Code Online (Sandbox Code Playgroud)
请注意, comp实际上不是Checkbox 的实例;而是作为 com.vaadin.flow.component.contextmenu.MenuItem 返回,并且该项目不能转换为复选框。所以问题是,我如何取消选中给定的复选框?