-
Notifications
You must be signed in to change notification settings - Fork 815
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
Input and TextArea have cursor blinking even though terminal window is not focused #4263
Comments
We should implement these ANSI codes. Should be straightforward in theory. Enable the escape sequences, and convert them to AppFocus and AppBlur. Talk to @willmcgugan if more clarification is needed. |
With an eye on the motivation for this: it would seem that there's benefit to the widgets in the focus chain knowing when |
What is the benefit? |
Just thinking about if there's utility for it when it comes to a random developer wanting to implement functionality on a widget that's related to having focus or not, and wanting to take into account if there emulator window has focus (while I recognise that it's not done with |
The behaviour (in Textual-web) is that when the window loses focus, the focused widget is blurred. When the window regains focus, the previously blurred widget is focused again. This feels like an extension of the regular focus mechanism. I can't think why a developer would want to do something different. You can always check if the windows as focus with |
Ahh, cool, so it seems this is already taken care of anyway? Nice. |
Something to consider, perhaps as part of this, or as a fresh issue: it seems that the current implementation of from pathlib import Path
from textual.app import App, ComposeResult
from textual.widgets import Digits, Input, TextArea
class AppFocusBlurApp(App[None]):
def compose(self) -> ComposeResult:
yield Digits("")
yield Input(placeholder="Here's an input to help test")
yield TextArea(Path(__file__).read_text(), language="python")
def update_digits(self) -> None:
self.query_one(Digits).update(
("1" if self.app_focus else "0") * (self.size.width // 3)
)
def on_mount(self) -> None:
self.update_digits()
def watch_app_focus(self) -> None:
self.update_digits()
if __name__ == "__main__":
AppFocusBlurApp().run() if I focus the |
For looking at Textualize/textual#4263
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Discussed in #4259
Originally posted by villekr March 5, 2024
Following simple app has Input and TextArea widgets. Focus transitions between them as expected. However, when I focus some other window than iTerm2 running textual app then cursor still keeps on blinking on the previously focused widget. I would expect that by default focus is removed alltogether from app when other window gets focus. Or is this something app needs to be specifically configured?
I added also _on_app_focus annd _on_app_blur event handlers for debugging, but they are not invoked. Maybe these are only relevant for textual-web based on comments (# Required by textual-web to manage focus in a web page.)As this might be platform/terminal related here's the configuration I have.
macOS Sonoma: Version 14.3
iTerm2: Build 3.4.23
Python 3.12
Textual 0.52.1
The text was updated successfully, but these errors were encountered: