caret

Placeholder in contenteditable - focus event issue

人盡茶涼 提交于 2019-11-28 15:27:49
I have been trying to ask this before, without any luck of explaining/proving a working example where the bug happens. So here is another try: I’m trying to replicate a placeholder effect on a contenteditable DIV. The core concept is simple: <div contenteditable><em>Edit me</em></div> <script> $('div').focus(function() { $(this).empty(); }); </script> This can sometomes work, but if the placeholder contains HTML, or if there some other processing being made, the editable DIV’s text caret is being removed, and the user must re-click the editable DIV to be able to start typing (even if it’s

Hide input caret of TextField in JavaFX8

人盡茶涼 提交于 2019-11-28 13:51:24
I would like to hide the input caret of a TextField in JavaFX8. I already tried to set the text fill to white (my TextField has a white background), but then my user input also disappears. The problem is that the textfield still needs focus, so I also thought of some EventHandler which listens to user input, and focusses on the textfield when a key is pressed, but then I would miss the first key typed. Anyone that knows how to do this? Or is it not possible in JavaFX8? jewelsea Update for Java 8u40 A CSS style class was added to JavaFX to switch on and off the text field caret which is (in

Styling text input caret

我是研究僧i 提交于 2019-11-28 13:21:54
I want to style the caret of a focused <input type='text'/> . Specifically, the color and thickness. If you are using a webkit browser you can change the color of the caret by following the next CSS snippet. I'm not sure if It's possible to change the format with CSS. input, textarea { font-size: 24px; padding: 10px; color: red; text-shadow: 0px 0px 0px #000; -webkit-text-fill-color: transparent; } input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #ccc; text-shadow: none; -webkit-text-fill-color: initial; } Here is an example: http://jsfiddle.net/8k1k0awb/ 'Caret'

How do I get window.getselection to work for an input type=text field

坚强是说给别人听的谎言 提交于 2019-11-28 10:57:59
I have a contenteditable div, like so: <div id="test" contentEditable="true" style="width: 600px; height:300px;">Lorem ipsum dolor sit amet</div> for which I use the following code: <input type="button" value="Click me" onclick="alert(window.getSelection().focusOffset.toString());"></button> Clicking on the button when I move the caret around in the div, returns to me the actual position (offset) of the caret within the div. The problem is when I replace the contenteditable div with an input type=text or password control, and keep the contenteditable property=true, and click on the button, I

TextBox Cursor is NOT blinking

与世无争的帅哥 提交于 2019-11-28 09:57:52
问题 I have a WPF datagrid (4.0) with a custom column (derived from DataGridTextColumn). In GenerateEditingElement I create a custom textbox control (with an additional button) and like to set the cursor into it so that the user can directly start editing. The closest I get is that the caret is shown but is not blinking and I need an additional click to start editing. All other stuff (binding, ...) is working nicely Any ideas? 回答1: Since the caret is shown, but not blinking, then I am guessing

How to get caret position within contenteditable div with html child elements?

橙三吉。 提交于 2019-11-28 09:26:40
I am working with a contenteditable div that will have the option to have inline html elements such as tags in the text flow. At certain points I need to grab the caret position but have found that with the example code the position returned is incorrect if the caret is after an html child element. I need a cross browser solution that will allow me to store the position of the caret so that it can be restored a split second later even with the presence of html elements in the text flow. Example: http://jsfiddle.net/wPYMR/2/ Tim Down I've answered a very similar question here: Editing Iframe

Use of caret symbol( ^ ) in Ruby

只愿长相守 提交于 2019-11-28 08:59:54
1 ^ 1 # => 0 1 ^ 2 # => 3 5 ^ 6 # => 3 These are the results I am getting. Can, please, somebody explain how ^ works? It's a bitwise XOR operator. For each bit in the binary representation of the operands, a bitwise XOR will get a 1 bit if one of the corresponding bits in the operands is 1, but not both, otherwise the XOR will get a 0 bit. Here's an example: 5 = 101 6 = 110 5 ^ 6 = 011 = 3 来源: https://stackoverflow.com/questions/7163093/use-of-caret-symbol-in-ruby

Set caret position at a specific position in contenteditable div

荒凉一梦 提交于 2019-11-28 08:30:55
SEE BEFORE MARKING DUPLICATE/DOWNVOTING The contenteditable div will not have child elements I do not want to set the position at the end of the div I do not want a cross-browser solution , only Chrome support required Only vanilla JS , no libraries. I have seen many many solutions. Many by Tim Down, and others. But none does work. I have seen window.getSelection , .addRange etc. but don't see how they apply here. Here's a jsfiddle . (Tried) Code: var node = document.querySelector("div"); node.focus(); var caret = 10; // insert caret after the 10th character say var range = document

get last character before caret position in javascript

自作多情 提交于 2019-11-28 07:40:30
I am about to implement Facebook like in integration in my contenteditable div where if i give '$' and some character like 'a' i need a auto-suggestion which should pop up near my caret position. I need to know how to find out the last character before caret position either in JavaScript for IE and Other browsers. I have access to the Jquery library. (function($) { $.fn.getCursorPosition = function() { var input = this.get(0); if (!input) return; // No (input) element found if ('selectionStart' in input) { // Standard-compliant browsers return input.selectionStart; } else if (document

Textarea X/Y caret coordinates - jQuery plugin [duplicate]

三世轮回 提交于 2019-11-28 04:53:28
问题 This question already has answers here : How do I get the (x, y) pixel coordinates of the caret in text boxes? (3 answers) Closed 5 years ago . I'm looking to get the X/Y coordinates of the caret within a textarea on key down. I've searched vigorously but without any luck whatsoever, it seems you can get the position, but not the on-screen X/Y coordinates. 回答1: The only viable way of doing this, AFAIK: Append the contents of the TEXTAREA to a DIV Append the DIV to the DOM Place a SPAN inside