selection

Javascript surroundContents on selection doesn't work as expected if used on part of an already selected element

核能气质少年 提交于 2019-12-24 04:59:31
问题 I 'de like to higlight text selected by the user and copy it over to a text box. The latter part works great. But highlighting of the selected text fails if I try to highlight part of an already highlighted text. Here's a JSFiddle Try selecting the text on the right box, then try to select part of your previous selection. Any ideas? The relevant code: function highlightSelected() { var selection = getSelected(); var range = selection.getRangeAt(0); var newNode = document.createElement("span")

Detect the type of Selection in a Worksheet just deactivated, in any open Workbook

限于喜欢 提交于 2019-12-24 04:41:27
问题 I want a method to inquire, after changing the ActiveSheet ( EDIT: of any open Workbook ): Detect the type of Selection in the previous active sheet (of most importance, if it was a ChartObject or Range ). If it is a Range , get the address. Is this possible ...? EDIT : ... (cont.) Without additional Activating/Deactivating to inquire (preferred). With additional Activating/Deactivating to inquire. Note that adding code to ThisWorkbook only affects that Workbook. So, I guess that something

JavaFX TableView change selected cell colour

这一生的挚爱 提交于 2019-12-24 03:23:13
问题 I have a JavaFX TableView and a ListView and they both use custom cell factories. In particular I have overridden updateItem method in order to bind a particular CSS class based on cell value. This is part of my CSS file: .tissueCell { -fx-text-fill: #F5AD11; } .tissueCell:selected { -fx-background-color: #F5AD11; -fx-text-fill: white; } .significantDataCell { -fx-background-color: yellow; -fx-text-fill: black; } .significantDataCell:selected { -fx-background-color: white; -fx-text-fill:

What is the best way to determine what JRadioButton is selected?

依然范特西╮ 提交于 2019-12-24 02:35:31
问题 Currently I'm getting the selected button in this way, but I don't if this is the right/best method. MAybe there something more easy or object oriented than this. private int getFilterType(JRadioButton... buttons) { for (int i = 0, n = buttons.length; i < n; i++) { if (buttons[i].isSelected()) { return i + 1; } } return buttons.length + 1; } 回答1: I like using the ButtonGroup itself for this. i.e., import java.awt.GridLayout; import java.awt.event.ActionEvent; import javax.swing.*; public

Which event a selection of text trigger in Java JTextArea?

蓝咒 提交于 2019-12-24 02:26:10
问题 I want to monitor the selection of text into the a JTextArea. I don't know what event a selection of text triggers. I just want to enable some of the menu items as soon as some text is selected out of the JTextArea like copy and cut options into the menu. What should I monitor for that? 回答1: I don't know about any "selection listeners" for text components (although they might be useful), but you could use a CaretListener to monitor changes to the caret position and check the selection state..

Which event a selection of text trigger in Java JTextArea?

故事扮演 提交于 2019-12-24 02:26:05
问题 I want to monitor the selection of text into the a JTextArea. I don't know what event a selection of text triggers. I just want to enable some of the menu items as soon as some text is selected out of the JTextArea like copy and cut options into the menu. What should I monitor for that? 回答1: I don't know about any "selection listeners" for text components (although they might be useful), but you could use a CaretListener to monitor changes to the caret position and check the selection state..

WPF DataGrid - Retain selection when disabling

假如想象 提交于 2019-12-24 00:49:35
问题 I have been struggling with this for a while now. I have a Master / Details layout in my application, and am faced, like many others, with the problem of the DataGrid loosing its selection when disabling it. Essencialy, after selecting an element from the list to populate a series of fields, the user presses "Edit", wich disables the DataGrid and enables all of the form's fields. Pressing the "Save" button will revert these actions after saving the data... Pretty strait forward. I am on

Firefox - how to get selected text when using double click

荒凉一梦 提交于 2019-12-23 20:47:40
问题 I created a contentEditable div with a text portion and a link. Double clicking the link will select the link text. <div contentEditable="true"> This is a text and <a href="http://www.google.com">This_is_a_link</a> </div> Afterwards calling document.getSelection().getRangeAt(0).startContainer will return the div: // => <div contenteditable="true"> Instead of the link. I cannot find a way to find which part of the div is selected. See this jsfiddle (double click the "This_is_a_link" and there

In selection, can the focusOffset be before the anchorOffset?

南笙酒味 提交于 2019-12-23 19:10:13
问题 In programmatically defining a range/selection in JavaScript, is it not possible to have the focusOffset in the range be before the anchorOffset? How do we define a right to left selection then? a JS fiddler link for example: http://jsfiddle.net/johncch/ejVab/1/ 回答1: The way to create a "backwards" selection is slightly non-obvious. It can't be done by simply selecting a Range via the selection addRange() method because ranges are intrinsically directionless. You need to use the extend()

contenteditable selection of text not working

家住魔仙堡 提交于 2019-12-23 10:04:56
问题 I am faced with following: when I try to select text in a contenteditable element and the end of the selection is the start of the element content, then no select event is fired and there are no Selection and Range objects. Could somebody please give me any advice on why this might occur or how I can prevent this? Code responsible for getting selection range: $('div[contenteditable="true"]').bind("mouseup keyup touchend", function() { lastCaretIndex = getSelectionRange(); }); function