caret and anchor stale after selectRange with listeners
See original GitHub issueIf you attempt to use selectRange
to update caret and anchor positions that have attached listeners, the caret and anchor potitions will be stale.
@Test fun `sscce`(){
val underTest = StyleClassedTextArea()
//comment out this line of code and the test passes
val dontCare = Bindings.createStringBinding(Callable { "binded" }, underTest.caretPositionProperty(), underTest.anchorProperty())
underTest.appendText("asdf")
//act
underTest.selectRange(1, 2)
//assert
assertThat(underTest.selectedText).isEqualTo("s") //OK
assertThat(listOf(underTest.anchor, underTest.caretPosition)).isEqualTo(listOf(1, 2)) //fail
//actual: 0, 2
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Firing an event when the caret gets within a particular div/span ...
This will let you know when your caret position is in an anchor node containing an @. $('#content').on('mouseup keydown keyup', ...
Read more >third_party/WebKit/Source/web/WebViewImpl.cpp - Google Git
Constants for viewport anchoring on resize. ... static const int minReadableCaretHeight = 16; ... stale if this WebView is embedded in another one....
Read more >Safari Technology Preview Release Notes - Apple Developer
Many of the new Safari 16 features are now available in Safari Technology Preview 147: Live Text. Select and interact with text in...
Read more >Micetro by Menamp;Mice Documentation
The DHCP software (ISC DHCP) on the Men&Mice Virtual Appliances was patched for the ... or the FQDN of the availability group listener:....
Read more >Developers' handbook - MuseScore
Accessibility with focus on visually impaired musicians ... Audience Score Following: score following for audiences using node.js - Video ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jugen No I did mean anchor position. The caret appears to be working correctly.
Firstly: the use case is to have a richTextFX text area, with a couple of labels bound to metadata about that text areas selection --a pretty common thing if you look at gedit or notepad++.
I’ve found that if I leave my selection-listeners on the text area it changes the behaviour of the text area. Text selection with the mouse becomes stunted and heavily prone to artificially moving the caret to the end of the document or the anchor to the beginning of the document. This is what lead to the original report. Since your fix the behaviour got better but it is not corrected. If I leave my selection-listeners on the text area, I still find it selecting the wrong ranges frequently.
I have tried to get this down to an SSCCE but have had difficulty.
But I have found a workaround: rather than bind to the
anchorProperty
and thecaretPositionProperty
, I’m simply binding to theselectedTextProperty
.I still need to do some work here, I’ll let you know when I’ve got something reasonably actionable for you, but this one is tricky to run down.
probably what an “SSCCE” is going to look like is a live UI with some console output, and then a statement that “this console output should not be here”.
Umm, did you maybe mean caret position and not anchor position ? Otherwise can you provide more information.