SwiftUI TextField cursor colour

EDIT: as pointed out below and in the documentation, my original answer (below) is now deprecated and you should use .tint instead. Or if you want all text fields and other UI elements in your app to be the same you can customize your app’s global accentColor. Original answer: Tried it out and .accentColor does … Read more

jquery Setting cursor position in contenteditable div

Maybe I’m misreading the question, but wouldn’t the following do (assuming an editable <div> with id “editable”)? The timer is there because in Chrome, the native browser behaviour that selects the whole element seems to trigger after the focus event, thereby overriding the effect of the selection code unless postponed until after the focus event: … Read more

Clojure caret as a symbol?

^ is “the meta character” it tells the reader to add the symbol starting with ^ as metadata to the next symbol (provided it is something that implements IMetas) user=> (def x ^:IamMeta [1 2 3]) #’user/x user=> x [1 2 3] user=> (meta x) {:tag :IamMeta} user=> You can learn a lot about how … Read more

Get element node at caret position (in contentEditable)

Firstly, think about why you’re doing this. If you’re trying to stop users from editing certain elements, just set contenteditable to false on those elements. However, it is possible to do what you ask. The code below works in Safari 4 and will return the node the selection is anchored in (i.e. where the user … Read more

Carets in Regular Expressions

^ only means “not the following” when inside and at the start of [], so [^…]. When it’s inside [] but not at the start, it means the actual ^ character. When it’s escaped (\^), it also means the actual ^ character. In all other cases it means start of the string or line (which … Read more

Placeholder in contenteditable – focus event issue

Here is a CSS only solution augmenting some of the other answers:- <div contentEditable=true data-ph=”My Placeholder String”></div> <style> [contentEditable=true]:empty:not(:focus)::before{ content:attr(data-ph) } </style> EDIT: Here is my snippet on codepen -> http://codepen.io/mrmoje/pen/lkLez EDIT2: Be advised, this method doesn’t work 100% for multi-line applications due to residual <br> elements being present in the div after performing a … Read more

Get caret position in HTML input?

-> selectionStart <!doctype html> <html> <head> <meta charset = “utf-8”> <script type = “text/javascript”> window.addEventListener (“load”, function () { var input = document.getElementsByTagName (“input”); input[0].addEventListener (“keydown”, function () { alert (“Caret position: ” + this.selectionStart); // You can also set the caret: this.selectionStart = 2; }); }); </script> <title>Test</title> </head> <body> <input type = “text”> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)