Skip to content

TextInput: Fix cursor and anchor offset properties not being dirty or… #8479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tronical
Copy link
Member

… reporting wrong values when the text changes

Bite the bullet and use a proxy property with a binding.

Fixes #331

… reporting wrong values when the text changes

Bite the bullet and use a proxy property with a binding.

Fixes #331
@tronical
Copy link
Member Author

This is still missing the bit about emitting cursor-position-changed, and since cursor and anchor typically change at the same time, I'm thinking it might make more sense to combine them both into one single Property to safe resources.

@ogoffart
Copy link
Member

This is still missing the bit about emitting cursor-position-changed

Maybe we need a changed xxx in the implementation of the LineEditBase/TextEditBase ?

@tronical
Copy link
Member Author

I was thinking the same, but OTOH the callback is public API in TextInput and it was nice if it worked also when changing text.

@ogoffart
Copy link
Member

Then we could perhaps have a PropertyTracker or ChangedTracker in the TextInput (and we wouldn't need the proxy bindings)

tronical added 3 commits May 20, 2025 17:33
If we already have the text, avoid querying the property that has a binding that will query the text again.
pub cursor_position_byte_offset: Property<i32>,
pub anchor_position_byte_offset: Property<i32>,
pub unchecked_cursor_position_byte_offset: Property<i32>,
pub unchecked_anchor_position_byte_offset: Property<i32>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a #[repr(C)] struct CursorPosition { cursor_pos: i32, anchor: i32 } `
then we can put that in a Property.
(But doesn't have to be in this PR, this is just a thought)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TextInput::cursor_position and anchor_position are not up-to-date after changing TextInput::text
2 participants