有谁知道为什么会产生XamlParseException"无法将类型'System.Windows.Controls.ContextMenu'的内容添加到'System.Object'类型的对象中":
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas ClipToBounds="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="Remove" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
以下工作正常吗?
<ItemsControl>
<ItemsControl.Resources>
<ContextMenu x:Key="NodeContextMenu">
<MenuItem Header="Remove" />
</ContextMenu>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas ClipToBounds="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="ContextMenu" Value="{StaticResource NodeContextMenu}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud) 我花了大约3天试图让这个工作,但无济于事.
我是VS.NET可扩展性的新手,我发现很难调试我的问题.
我已经尝试过这里介绍的代码:Visual Studio加载项 - 向solution-explorer添加一个上下文菜单项
无法使它工作.调试它并没有抛出任何异常.另外,我宁愿使用AddIn而不是Package.
有谁知道:
提前致谢.
c# visual-studio-addins contextmenu visual-studio-2010 solution-explorer
我需要在finder中为文件图标添加一个上下文相关的菜单.所以基本上如果我右键单击,例如"filename.txt"图标,子菜单应弹出"打开","获取信息"等,但应该有一个额外的项目,例如"我的程序".如果用户选择"我的程序"菜单选项,系统将执行:"my_program.rb filename.txt".
我有32位Mac OS 10.6.
我检查了堆栈溢出,我有发布的解决方案,但他们有点困惑.首先,根据这个堆栈溢出文章,你必须"添加一个启用共享工具的服务",但这对我来说很困惑.什么是"服务"?这是一个特殊挂钩操作系统的程序吗?
还有一篇关于"提供服务"的苹果文章,但我再次对此感到困惑.ruby脚本可以算作"服务"吗?或者我必须在目标C中做一些奇怪的Cocoa事情来访问子菜单然后再参考那里的脚本?
有更简单的方法吗?也许是一个我尚未遇到的开源程序?
我想获取光标的当前记录,而不仅仅是ID,以便我可以操作上下文菜单.
我在这里看到这个示例,向您展示如何获取ID:
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case DELETE_ID:
AdapterView.AdapterContextMenuInfo info=
(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
delete(info.id);
return(true);
}
return(super.onOptionsItemSelected(item));
}
Run Code Online (Sandbox Code Playgroud)
这很棒,因为它允许我获取所单击的上下文菜单的相应SQLite数据库ID,这将允许我编写一个函数来进行查找.但我当然可以重用当前的光标吗?
我试过这样做:
Cursor c = (Cursor) this.getListAdapter().getItem((int) info.id);
String itemPriority = c.getInt(1);
Log.v(TAG, "Current item:" + itemPriority);
Run Code Online (Sandbox Code Playgroud)
但是光标线似乎只返回数据库的模式而不是我之后的记录.
请有人请说清楚.
编辑:感谢@azgolfer我找到了解决方案.我使用fillData()方法来填充适配器.通常,这是在没有变量的情况下声明的.我不得不用一个字段变量重新定义这个方法.在onContextItemSelected中使curstor适配器可见的代码的相关部分在这里:
private void fillData() {
Cursor itemsCursor = mDbHelper.fetchAllItemsFilter(mListId, mStatusFilter);
startManagingCursor(itemsCursor);
mItemAdaptor = new ItemAdapter(this, itemsCursor);
this.setListAdapter(mItemAdaptor);
}
Run Code Online (Sandbox Code Playgroud) 我们正在开发一个包含文本编辑器的Web应用程序.它是用HTML5 + Javascript编写的.
我们已成功向我们的网络应用添加了自定义菜单,但我们尚未成功添加Google文档中的复制和粘贴功能.根据我们的理解,这可以使用可以访问OS剪贴板的Flash来实现.但是,我们希望避免使用该技术并使用替代方案 - 我认为Google也不会使用Flash.
有人能指出我们有效的替代方法吗?
谢谢.
我在.html示例中使用了contextMenu事件,当我长按DIV时它会被触发,但是现在它无法正常工作.在最新的IOS 8.2版本中有什么问题.这是示例代码,
<head>
<title></title>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#content").on("contextmenu", function () {
alert("CM");
});
});
</script>
</head>
<body>
<div id="content" style="height:300px; width:300px; background-color:gray;"></div>
</body>
Run Code Online (Sandbox Code Playgroud)
这是工作样本
请有人帮我这个.
我有一个要求,iPad 需要支持右键单击现有网站。按照惯例,在支持触摸的设备中,右键单击会转换为长按事件。我已经在 Android 设备的 Chrome 中进行了测试,它可以工作,但在 iPad(iPad Air 2、10.3)的 Safari 中却出现问题。仅供参考,我正在使用这个演示网站:
http://wwwendt.de/tech/demo/jquery-contextmenu/demo/
这可能是 iOS 设备中 Safari 的错误吗?
因此,我希望可以以最有用的方式问这个问题。我对编码非常陌生,在尝试推动自己时,我决定尝试使用React而不使用任何教程来重新创建Minesweeper。我已经获得了很多功能,但确实停留在这部分上。我正在使用事件侦听器“ onContextMenu”注册右键单击以“标记”程序中的地雷。但是我找不到正确的隔离方法,或者这是一个语法问题,导致菜单无法同时弹出。在JS中,仅在事件侦听器上返回false似乎非常简单,但我无法在React中弄清楚。
我目前正在使用“ onContextMenu”来处理右键单击,并调用一个函数来处理带有该事件侦听器的标志分配。我还可以在函数内禁用contextMenu的显示吗?
感谢您提供的任何帮助!
现在正在渲染的div如下所示:
<div
contextMenu="none"
className="square"
onContextMenu={() => this.props.rightClick(props.arrayVal)}
onClick={() => {this.props.playerTurn(this.props.index)}}
style={{color:COLORS[this.props.arrayVal], backgroundImage:this.backgroundChooser(this.props.arrayVal)}}
>
{this.squareContent(this.props.arrayVal)}
</div>
Run Code Online (Sandbox Code Playgroud)
被调用的函数如下所示:
rightClick = (id) => {
let { board, gameWon, minesLeft } = this.state
let mineCount = minesLeft
let move = board
if (gameWon === false) {
if (board[id] === -1) {
move[id] = 9
mineCount -= 1
} else if (board[id] === 9) {
move[id] = "?"
mineCount += 1
} else if (board[id] === "?") {
move[id] = …Run Code Online (Sandbox Code Playgroud) highcharts 中是否有任何属性可以用来删除使用 JavaScript 出现在该柱形图中的图表上下文菜单(看起来像右侧的汉堡菜单) ?
这个选项默认出现在 highchart 中吗?我还有一个折线图,但默认情况下没有图表上下文菜单。另外,如果我想向该折线图添加图表上下文菜单,我该怎么做?
Highcharts.chart('container', {
chart: {
type: 'column',
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
newValue = Math.random() * 100;
series.update({
data: [newValue],
}, true)
}, 1000);
}
}
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: …Run Code Online (Sandbox Code Playgroud)我想为 iOS 13+ 自定义上下文菜单上的操作按钮
菜单是这样的:
我想我可以像 UIAlertController 操作一样设置自定义字体,如下所示:
let action = UIAction(title: "asdasd") { _ in}
let attributeString = NSMutableAttributedString(string: action.title)
attributeString.addAttributes([NSAttributedString.Key.font : font], range: NSMakeRange(0, action.title.count))
action.setValue(attributeString, forKey: "attributedMessage")
Run Code Online (Sandbox Code Playgroud)
但它不是这样工作的,那是怎么回事呢?