Giter Club home page Giter Club logo

Comments (8)

darrenburns avatar darrenburns commented on June 4, 2024 1

Cheers - I reckon this will be changing a True to a False somewhere 😄

from textual.

TomJGooding avatar TomJGooding commented on June 4, 2024

I had a quick look at this and found that if you set cursor_blink = False (needed for snapshot testing), the TextArea still has a cursor even after focussing then blurring:

from textual.app import App, ComposeResult
from textual.widgets import Input, TextArea


class TextAreaCursorApp(App[None]):
    def compose(self) -> ComposeResult:
        input = Input()
        text_area = TextArea()
        input.cursor_blink = False
        text_area.cursor_blink = False
        yield input
        yield text_area


if __name__ == "__main__":
    TextAreaCursorApp().run()

Then I spotted that the _on_blur method actually also seems to set the cursor to be visible which is confusing? Changing this to False has no effect, which suggests the cursor visibility must actually be updated elsewhere...?

def _on_blur(self, _: events.Blur) -> None:
self._pause_blink(visible=True)

EDIT: Ah-ha, I missed that it also has this watch method!

def watch_has_focus(self, value: bool) -> None:
self._cursor_visible = value
super().watch_has_focus(value)

from textual.

darrenburns avatar darrenburns commented on June 4, 2024

Oh yeah, the _on_blur can probably be removed. It was intended to ensure that the cursor remains visible when it's blurred for consistency. Otherwise the visibility of the cursor depended on when you blurred the widget.

I was thinking initialising self._cursor_visible to False in the constructor might be enough.

from textual.

TomJGooding avatar TomJGooding commented on June 4, 2024

Just to note for whoever picks this up (maybe me!), potentially any fix should also account for this issue:

from textual.

TomJGooding avatar TomJGooding commented on June 4, 2024

Oh yeah, the _on_blur can probably be removed. It was intended to ensure that the cursor remains visible when it's blurred for consistency. Otherwise the visibility of the cursor depended on when you blurred the widget.

Sorry I'm not sure I fully understand this - is that just the old implementation, or related to #2476?

from textual.

darrenburns avatar darrenburns commented on June 4, 2024

Sorry, I meant the _on_blur could be removed because we could handle the logic of pausing the blink insidewatch_has_focus instead, rather than doing blur-related stuff in 2 places. We'll probably need to pause blink in watch_has_focus with visible=False.

from textual.

darrenburns avatar darrenburns commented on June 4, 2024

I'm going to pick this up now.

from textual.

github-actions avatar github-actions commented on June 4, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.