Comments (8)
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.
from textual.
With an eye on the motivation for this: it would seem that there's benefit to the widgets in the focus chain knowing when AppFocus
and AppBlur
happens; I wonder if perhaps those events should be posted to the focused widget and allowed to bubble?
from textual.
What is the benefit?
from textual.
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 Focus
and Blur
with Input
and TextArea
, I'm thinking about any situations we've not considered yet that might be akin to the original motivation for the question that resulted in this issue).
from textual.
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 self.app.app_focus
.
from textual.
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.
Ahh, cool, so it seems this is already taken care of anyway? Nice.
from textual.
Something to consider, perhaps as part of this, or as a fresh issue: it seems that the current implementation of AppBlur
and AppFocus
, as seen in textual-web, causes focus to be fully lost. For example, while testing with this code:
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 Input
, Cmd-tab away to another window, then Cmd-tab back, I've lost my place in the form. It would be normal to expect focus to settle back where it was before once the app is focused again.
from textual.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
from textual.
Related Issues (20)
- `TabbedContent` styling affects child widgets HOT 1
- `TabbedContent` message mixup if `Tabs` inside a `TabPane`
- Mouse-driven focus does not behave as expected. HOT 2
- `Tabs.Cleared` documentation a little ambiguous HOT 3
- Disabled widgets prevent mouse scrolling HOT 1
- Discord invite link not working HOT 6
- Malformed @click links crash Textual application HOT 2
- How to link from docs to videos? HOT 2
- Loading Indicator page could use docs about `loading` attribute HOT 1
- Ability to replace text while keeping TextArea history HOT 4
- NoMatches error occurring when changing screens quickly in version 0.49+ HOT 14
- Hidden ListItem in ListView is selected when navigating with keyboard
- `Switch.action_toggle` name clash HOT 1
- Intermittently failing test (`test_pilot.py::test_pilot_target_on_widget_that_is_not_visible_errors`)
- Add indicators for the TabbedContent widget HOT 6
- Scrollbars may trap the mouse if hidden while the user is scrolling HOT 6
- TextArea CTRL-k behavior request HOT 7
- Try/except on all app
- Exception not being raised in tests HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textual.