问题标签 [selection]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3916 浏览

javascript - 打开 jQuery 对话框时如何保留文本选择

使用 jQuery 的对话框,我遇到了以下怪癖(在 FF3 中测试):

  1. 用户选择文本
  2. 在代码中,打开一个 jQuery 对话框
  3. BUG:文本被取消选中

(文本可以在文本区域中,也可以只是页面上的 HTML)

所以,对我来说,这似乎是一个有趣(和烦人)的错误或怪癖,但也许有一个很好的解释。最让我感兴趣的是,打开对话框后如何保留此文本选择?

这是一些代码:

谢谢!

0 投票
2 回答
2876 浏览

css - Cross browser way to hide selection display

I am making a browser based javascript game. As such, within the game there is nowhere users need to copy/paste text. However there are many places where the user needs to click and drag to make selections in the game.

Within the game there are many cells, internally just normal table cells, with a non breaking space to stop them collapsing in firefox (I could stop the collapsing in IE, Safari and Opera with CSS, but for some reason it didn't work in firefox so I resorted to non breaking spaces), with either a solid background colour or a background image.

As the player drags a selection across them, the game highlights the cells by changing the background colour. However, the browser also highlights the non breaking spaces, leaving grey rectangles across some of the cell.

Also the browser uses a different way to determine what is selected than the game.

e.g. in a 5 x 5 square, if the user selects (1, 1) to (3, 3), the game highlights the following selection:

but the browser highlights the non breaking spaces in the following:

Is there any way to stop the browser selection styling showing through? At the very least in firefox and Chrome, but preferably cross browser.

0 投票
1 回答
3386 浏览

treeview - ASP.NET Treeview 控件和客户端 javascript - 突出显示选定的树视图节点

如何执行以下操作 - ASP.NET 2.0 TreeView 和使用 JavaScript选择选定节点

我通过阅读这篇文章来尝试这个,但它没有在 asp.net 2.0 树视图控件上找到 getTreeNode() 属性。

0 投票
1 回答
226 浏览

c# - 创建矩形文本选择

您好,我想弄清楚是否可以在 c# 的标准文本框控件中进行矩形文本选择(如在 Jedit 中)?

0 投票
1 回答
4370 浏览

wpf - 列表视图选择颜色

我正在玩 wpf,我看到了以下文章: WPF ListView Inactive Selection Color

我想做类似的事情。我想在选择列表视图项时在它周围放置一个边框,并且我不想更改背景颜色。我想要这个的原因是我想要一个颜色编码的列表视图,并且我仍然想在选择它时看到它的颜色,但我想知道它是通过它周围有边框来选择的。

有任何想法吗?

更新:

我尝试了下面的答案,它让我成功了一半,它确实在 listviewitem 周围设置了一个边框,但它覆盖了我的背景颜色。我无法得到我尝试过的正确语法(注意 BasedOn):

然后我尝试了这个:

两次尝试都只是将背景设置为白色(或我不知道的透明)。我知道这只是语法,我很感激朝着正确的方向再次轻推:)

0 投票
1 回答
6154 浏览

wpf - 文本框焦点上的 ListBoxItem 选择

我有一个使用以下 DataTemplate 显示项目的 ListBox:

我使用透明、只读、无边框的 TextBox 而不是 TextBlock,因为我希望用户能够选择要复制的文本。我应该采取不同的做法吗?我怎样才能这样写,以便当用户单击 TextBox 时, ListBoxItem 也会被选中?

谢谢!

0 投票
2 回答
1398 浏览

javascript - 如何在 Safari 中通过 JavaScript 确定/操作文本区域的选择?

我有一些 JavaScript 代码可以做两件事:

  • 从文本区域检索选定的文本
  • 为所选文本添加前缀和后缀

该代码当前使用 textarea 的selectionStartselectionEnd属性来确定选择的开始/结束位置,提取选择文本并对其进行处理,然后重新写入 textarea 的值,并在正确的位置插入前缀和后缀。

此实现在 Firefox 中运行良好,但在 Safari 中不起作用。显然WebKit 中不存在selectionStartand属性。selectionEnd(我怀疑该代码在同样基于 WebKit 的 Google Chrome 中也不起作用,尽管我没有对此进行测试。)

如何在 Safari 中执行这两个操作?

0 投票
5 回答
2027 浏览

javascript - 如何防止在 Opera 中按 Ctrl+单击时出现“另存为(图像)”对话框

我必须创建一个图像库,用户可以在其中选择一些图像然后处理它们。选择应通过鼠标的 Ctrl+LeftClick 完成。它在 FF 和 IE8 中运行良好,但是当我在 Opera 中按住 Ctrl 并单击时,会出现新对话框“另存为”,这会导致保存单击的图像。

如何防止在 Opera 中打开对话框?(可能是系统设置)我还没有找到任何解决方案。自 2008 年 6 月以来, Opera的问题 仍未得到解答 :(

甚至可能吗?Ctrl+Click 是操作系统中的标准方式,这可能是问题 - 使桌面行为适应网络。

0 投票
2 回答
238 浏览

jquery - 一个关于 Jquery 的选择问题

在下面的代码中,当我单击 lnkSecc 时,我希望选择 lnkSecc 之后的第一个 div 下的复选框,其中 id 是 Grup。我该怎么做?

0 投票
1 回答
1603 浏览

richtextbox - 富文本框圆角选择高亮

我一直在网上搜索有关如何编写语法高亮文本框的代码,并且我已经完成了大部分工作。但我一直很喜欢 mac 的圆角 xcode 选择突出显示。最近我在 inType 文本编辑器中看到了这种类型的选择突出显示。这张图片更好地解释了我希望在富文本框中获得的效果。

很难用语言解释,所以你可以在这里查看图片http://www.blackackle.com/corner.jpg

关于如何获得此结果的任何想法?我在 C# .NET 上进行编码,但如果解决方案需要任何其他语言,那也没关系。

提前致谢