Skip to content
Discussion options

You must be logged in to vote

The issue here is that Input has an on_focus handler which always sets the cursor position to the end of the input (funnily enough I was wondering about the design choice there just this morning). While you are setting the cursor position after calling focus, I would imagine that due to the async nature of Textual the on_focus of the Input is happening after your on_mount has finished (see the code for Widget.focus if you want to dive deeper).

Unfortunately it seems that, right at the moment, there's no easy way to override that behaviour -- the obvious thing of making a custom input widget from Input and just overriding on_focus doesn't quite work out. It's a little bit hacky, but here's…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by learnbyexample
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants