Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Custom widget inheritance #3826

Closed
vpet98 opened this issue Dec 7, 2023 · 0 comments
Closed

Custom widget inheritance #3826

vpet98 opened this issue Dec 7, 2023 · 0 comments

Comments

@vpet98
Copy link

vpet98 commented Dec 7, 2023

I have been trying to build me own widget that I want it to be mostly like Input widget, but without ability to modify text, so like a text with a cursor that can be moved in it.

To do so, I have a new class that inherits from Input class and I override some of the methods. While doing so, I noticed that some of the methods like _on_focus and _on_paste are not overriden as I expected. While I can verify that my methods are indeed executed, I also see the effects from the ones of the Input class to take place as if they are executed after my methods.

For example, if I change the _on_focus to have the cursor at start rather than end like this:

def _on_focus(self, _: Focus) -> None:
    self.cursor_position = 0  # modified line
    if self.cursor_blink:
        self._blink_timer.resume()
    self.app.cursor_position = self.cursor_screen_offset

I still see the cursor appear in the end of the text instead of it appearing over the first character as I would expect.

Is there any explanation of why this happens and how I can prevent it?

Thank you

@Textualize Textualize deleted a comment from github-actions bot Dec 7, 2023
@Textualize Textualize locked and limited conversation to collaborators Dec 7, 2023
@davep davep converted this issue into discussion #3827 Dec 7, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant