我一直在编写实用程序并通过 Shell 键 * 上的 Regedit 将它们映射到上下文菜单,但我不知道如何像一些更流行的实用程序那样创建子菜单。
例如,如果我有三个脚本将文件移动和重命名到三个不同的文件夹,那么现在我有三个不同的上下文菜单条目。我更喜欢有一个名为“移动并重命名...”的扩展至这三个。
我需要弄清楚如何以编程方式从单独的应用程序的系统托盘图标中查找并选择上下文菜单项。我能想象实现这一点的唯一方法是使用 mouse_event() 和一些硬编码的 x/y 值,并将图标设置为始终显示。除了一般的硬编码的黑客使用之外,这里的问题是假设图标将保留其位置(这可能会在其他应用程序加载/卸载时中断)。我想知道是否有人知道任何其他方法来解决这个问题?
我正在制作一个 HTML 5 游戏,需要使用右键单击来控制播放器。
我已经能够通过执行以下操作来禁用右键单击上下文菜单:
<body oncontextmenu="return(false);">
Run Code Online (Sandbox Code Playgroud)
然后我注意到,如果按住 Shift 并右键单击,Firefox 中仍然会打开上下文菜单!
所以我也通过添加这个 JS 来禁用它:
document.onclick = function(e) { if(e.button == 2 || e.button == 3) { e.preventDefault(); e.stopPropagation(); return(false); } };
Run Code Online (Sandbox Code Playgroud)
但是,如果您按住 Shift 键,然后在 Firefox 中双击鼠标右键,它仍然会打开!
请告诉我如何一劳永逸地禁用这个该死的东西(我什至愿意恢复到一些晦涩的、黑客的、不切实际的解决方案,只要它有效)。
我正在尝试使上下文菜单显示字符串列表。该应用程序包含一个可以编辑、删除和添加到组中的人员数据网格。我有一个 StudentGroup 类,它是一个人可以添加的不同组(StudentGroup 的成员之一是名称)。ViewModel 检索完整的组列表并将其放入可观察集合中。我试图使上下文菜单正常工作,以便每当用户右键单击并将鼠标悬停在“将用户添加到”-> 上时,它都会打开一个包含可观察集合的名称字符串的侧面菜单项。
这是我到目前为止通过在 StackOverflow 上查找类似问题所尝试过的方法,但它对我来说还没有奏效。
XAML:
<DataGrid.ContextMenu>
<ContextMenu AllowDrop="True" ItemsSource="{Binding Entries}">
<MenuItem Header="Edit" />
<MenuItem Header="Delete"/>
<MenuItem Header="Add User to">
<MenuItem.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</MenuItem.ItemTemplate>
</MenuItem>
</ContextMenu>
</DataGrid.ContextMenu>
Run Code Online (Sandbox Code Playgroud)
视图背后的 XAML 代码:
private TitleViewMode TVM=new TitleViewMode;
public Welcome()
{
InitializeComponent();
_grid1.ContextMenu.DataContext = TVM;
}
Run Code Online (Sandbox Code Playgroud)
视图模型
class TitleViewModel
{
public ObservableCollection<StudentGroup> Entries {get;set;}
private List<StudentGroup> sg1 { get; set;}
public TitletViewModel()
{
sg1 = GetGroups();
Entries = new ObservableCollection<StudentGroup>(sg1);
}
}
Run Code Online (Sandbox Code Playgroud) 我发现 "CommandFlags"=dword:00000040 将在条目下方添加一个分隔符,但仅添加到子菜单(在“subcommands”="" 字符串下)。示例在这里。
有没有办法在主上下文菜单中添加分隔符?
我正在使用的示例:
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Delete With Rimraf]
@="Delete With Rimraf"
"CommandFlags"=dword:00000040
Run Code Online (Sandbox Code Playgroud)
这没有分隔符。
我尝试使用contextMenu Plugin,但我得到$.contextMenu is not a function.
我像在演示中一样尝试过。
我无法弄清楚我做错了什么。
$(function() {
$.contextMenu({
selector: '.context-menu-one',
callback: function(key, options) {
var m = "clicked: " + key;
alert(m);
},
items: {
"edit": {name: "Edit", icon: "edit"},
"cut": {name: "Cut", icon: "cut"},
copy: {name: "Copy", icon: "copy"},
"paste": {name: "Paste", icon: "paste"},
"delete": {name: "Delete", icon: "delete"},
"sep1": "---------",
"quit": {name: "Quit", icon: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
}
});
$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
});
});Run Code Online (Sandbox Code Playgroud)
<script
src="https://code.jquery.com/jquery-3.3.1.min.js" …Run Code Online (Sandbox Code Playgroud)试图找到一些文本,然后右键单击该文本。该表是动态的,因此我无法假设知道要搜索的值所在的单元格位置或要单击的值。例如,我想找到一个名称,然后右键单击名称本身
右键菜单似乎被称为class = context menu,值为class = context_item(请参见附加的屏幕截图)(还包括 html)
我知道这部分有效,但它下面的其余部分有问题 - col = row.find_element(By.XPATH, '//a[contains(text() , "Luke Wilson")]')
回溯(最近一次调用):文件“C:\Users\AppData\Local\Programs\Python\Python36\ffox_Change_Create_Save_Stay_v2.py”,第 182 行,在 get_all_rows_approval() 文件“C:\Users\AppData\Local\Programs\ Python\Python36\ffox_Change_Create_Save_Stay_v2.py”,第 164 行,在 get_all_rows_approval 菜单 = col.find_element_by_class_name("context_menu") 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\web \remote\webelement.py", line 398, in find_element_by_class_name return self.find_element(by=By.CLASS_NAME, value=name) File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages \selenium\webdriver\remote\webelement.py",第 654 行,在 find_element {"using": by, "value": value})['value'] 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py”,第 628 行,在 _execute 中返回 self._parent.execute(command, params ) 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 320 行,在执行 self.error_handler.check_response(response) 文件中“ C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py”,第 242 行,在 check_response 中引发 exception_class(message, screen, stacktrace) selenium.common。 exceptions.NoSuchElementException:消息:无法定位元素:.context_menu在 _execute 中返回 self._parent.execute(command, …
react-leaflet-context-menu 是leaflet.contextmenu 的react 版本。然而它使用原始的传单映射来实现反应中的插件而不是使用反应传单。
我在我的应用程序中采用了 react-leaflet,使用组件。我浏览了互联网,但没有多少示例来展示如何正确扩展 Map。
这是我的应用程序中的地图代码:
<LeafletMap
ref={m => {this.leafletMap = m;}}
center={this.state.center}
zoom={this.state.zoom}
maxZoom={this.state.maxZoom}
preferCanvas={this.state.preferCanvas}
contextmenu={this.state.contextmenu}
contextmenuWidth={this.state.contextmenuWidth}
contextmenuItems={this.state.contextmenuItems}>
<TileLayer
url={mapsource}
/>
<MarkerClusterGroup showCoverageOnHover={false} zoomToBoundsOnClick={false} maxClusterRadius={30}>
{CamMarkers}
</MarkerClusterGroup>
<ScaleControl imperial={false} metric={true}/>
</LeafletMap>
Run Code Online (Sandbox Code Playgroud)
我期望通过扩展 react-leaflet 的组件,它可以直接支持leaflet.contextmenu。道具 contextmenu、contextmenuWidth、contextmenuItems 将被输入到扩展组件,并在地图上右键单击时显示一些控件。
我的应用程序支持 iOS 13 暗模式,并为用户提供匹配系统外观或强制应用程序始终使用暗模式或亮模式的选项,而不管系统设置如何。
该应用程序还允许在用户按下 时显示上下文菜单UILabel。但是,当使用UIContextMenuInteractionDelegate方法呈现上下文菜单时,我找不到任何方法来覆盖菜单的深色/浅色外观,也找不到UITargetedPreview在上下文菜单出现和消失时动画的视图外观。
例如,如果 iOS 外观设置为浅色模式并且用户在应用程序中选择强制深色模式的选项,则上下文菜单显示为浅色。我想覆盖该行为,使它们看起来很暗 - 有什么方法可以实现这一目标吗?我似乎找不到overrideUserInterfaceStyle与上下文菜单相关的属性。
我使用的代码如下供参考。
// Setup code
if #available(iOS 13.0, *) {
self.textLabel.addInteraction(UIContextMenuInteraction(delegate: self))
}
// UIContextMenuInteractionDelegate
@available(iOS 13.0, *)
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
let text = self.text
return UIContextMenuConfiguration(identifier: nil, previewProvider: { return TextViewController(text: text) }) { [weak self] _ in
return self?.contextMenu(for: text)
}
}
@available(iOS 13.0, *)
private func contextMenu(for text: String) -> UIMenu { …Run Code Online (Sandbox Code Playgroud) 我正在关注本教程https://kylebashour.com/posts/context-menu-guide并试图重新利用此显示上下文菜单的代码段:
class TableViewController: UITableViewController {
let data: [MyModel] = []
override func viewDidLoad() {
super.viewDidLoad()
// Configure the table view
}
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let item = data[indexPath.row]
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in
// Create an action for sharing
let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in
print("Sharing \(item)")
}
// Create other actions...
return UIMenu(title: "", children: [share, rename, delete])
} …Run Code Online (Sandbox Code Playgroud) contextmenu ×10
windows ×3
ios ×2
javascript ×2
swift ×2
c# ×1
click ×1
html ×1
ios13 ×1
iphone ×1
jquery ×1
mvvm ×1
python ×1
python-3.x ×1
reactjs ×1
registry ×1
selenium ×1
system-tray ×1
winapi ×1
wpf ×1