在我的XAML文件中,我有一个像这样声明的ListBox:
<ListBox x:Name="lstDeck" Height="280" ItemsSource="{Binding Path=Deck}" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Content="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
在我的视图模型中,Deck是一个ObservableCollection,因此绑定直接显示我的集合的内容.
但是当我有几个值保持相同的值(例如"10"六次)时,ListBox中的选择有一个奇怪的行为:它选择2-3个元素而不是我点击的唯一元素.
此外,当我点击另一个listBoxItem时,它不会使之前选择的一个没有聚焦.
然后就不可能看到实际选择了哪个项目,也无法获得SelectedIndex值.
有人有想法吗?
我正在开发 Google Chrome 扩展程序。单击弹出窗口时,我希望 popup.html 文件中的输入框包含当前网页的选定文本。
示例文本框:
<input id="searchBox" type="text" />
Run Code Online (Sandbox Code Playgroud)
在网页中选择文本时,文本框应包含选定的单词。我试过,chrome.extension.getBackgroundPage().getSelection()但它不起作用。
javascript clipboard google-chrome selection google-chrome-extension
我有一个基本的表,像这样:
<table>
<tbody>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
在行上我有一个双击函数与jQuery:
$('tr').live('dblclick',function(){
dosomething();
return false;
});
Run Code Online (Sandbox Code Playgroud)
我还有一个名为tablednd的插件,它在行上使用mousedown/up函数.双击会导致单元格上的文本选择.
我怎么能阻止这个?
我想禁用按钮的动画是触摸或选择.我想模仿标签上发生选择的功能.我很熟悉按钮的属性与uilabel比较,因为我可以给出我的背景图像,它也可以帮助我解决更多问题.
请帮帮我吗?
我需要一个python脚本,它将使用xsel在其他应用程序中获取选定的文本,然后将其存储在var中。
谢谢
我已经为此尝试了很多方法并完成了数小时的研究,但它似乎永远不会对我有用.
这是我目前的代码,我不知道它为什么不起作用.
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
listBox1.SelectedIndex = listBox1.IndexFromPoint(e.X, e.Y);
if (e.Button == MouseButtons.Right)
{
contextMenuStrip1.Show();
}
}
Run Code Online (Sandbox Code Playgroud)
此外,我不关心可以删除的上下文菜单我只是想找到一种方法来鼠标右键选择我点击的项目.
有任何想法吗?
也许这是与浏览器相关的问题?我现在在Chrome上...
我想要完成的是允许用户使用光标保存他们在页面上选择(突出显示)的文本.
我有javascript/jQuery/ajax所有设置......当我通过控制台测试它时它就像一个魅力.
即 - 我选择一些文本,然后运行此命令.
alert(getSelected());
Run Code Online (Sandbox Code Playgroud)
我得到一个包含所选字符的警报弹出窗口.......所以它在理论上有效.
但是 - 当我想使用按钮拨打电话时,发生的事情是文本选择消失了FIRST,因此我无法查看/保存他们选择的内容.
<script>
$('#save').click(function(){
var selected_text = getSelected();
});
</script>
<div id="save"><img src="the_save_button.jpg" height="50" width="50" /></div>
Run Code Online (Sandbox Code Playgroud)
有没有办法在点击/点击"保存"DIV后保持文本选择?
开放给任何和所有解决方案!谢谢!
我使用此代码为不同颜色的ly jtable行着色:
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer()
{
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
final Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY);
return c;
}
});
Run Code Online (Sandbox Code Playgroud)
它有效,现在我想将用户选择的行着色为与上述颜色不同的另一种颜色:
table.setSelectionBackground(Color.RED);
Run Code Online (Sandbox Code Playgroud)
但它做了什么我怎样才能做到这一点?
先感谢您
资料来源:维基百科
使用堆或其他优先级队列数据结构也可以进行流式单遍部分排序。首先,将输入的前k个元素插入结构中。然后遍历其余元素,依次将每个元素添加到结构中,并删除最大的元素。每个插入操作还需要O(log k)时间,因此总共需要O(n log k)时间。
make one pass over the remaining elements, add each to the structure in turn, and remove the largest element。这与1)中描述的方法不同吗?我检查了这个问题,这个问题是它给了我当前选择的内容,但我想要dom元素.
我正在寻找一种方法来获取当前正在使用javascript编辑的元素的标记名.例如:
<article contenteditable=true>
<h2>Some List</h2>
<ul>
<li>Item 1</li>
<li>Item *caret here* 2</li>
<li>Item 3</li>
</ul>
</article>
Run Code Online (Sandbox Code Playgroud)
我希望能够将列表项放入javascript el变量中.所以我可以做的例如:
el.tagName
el.className
Run Code Online (Sandbox Code Playgroud)
有谁知道如何实现这一目标?Tx :)