Only apply select_on_focus in Input if the focus event wasn't produced from an app focus event.
This commit is contained in:
parent
98432b2fd9
commit
15e77c8150
3 changed files with 8 additions and 2 deletions
|
|
@ -4052,7 +4052,9 @@ class App(Generic[ReturnType], DOMNode):
|
|||
# ...settle focus back on that widget.
|
||||
# Don't scroll the newly focused widget, as this can be quite jarring
|
||||
self.screen.set_focus(
|
||||
self._last_focused_on_app_blur, scroll_visible=False
|
||||
self._last_focused_on_app_blur,
|
||||
scroll_visible=False,
|
||||
from_app_focus=True,
|
||||
)
|
||||
except NoScreen:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -736,6 +736,10 @@ class Focus(Event, bubble=False):
|
|||
self.from_app_focus = from_app_focus
|
||||
super().__init__()
|
||||
|
||||
def __rich_repr__(self) -> rich.repr.Result:
|
||||
yield from super().__rich_repr__()
|
||||
yield "from_app_focus", self.from_app_focus
|
||||
|
||||
|
||||
class Blur(Event, bubble=False):
|
||||
"""Sent when a widget is blurred (un-focussed).
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ class Input(ScrollView):
|
|||
|
||||
def _on_focus(self, event: Focus) -> None:
|
||||
self._restart_blink()
|
||||
if self.select_on_focus:
|
||||
if self.select_on_focus and not event.from_app_focus:
|
||||
self.selection = Selection(0, len(self.value))
|
||||
self.app.cursor_position = self.cursor_screen_offset
|
||||
self._suggestion = ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue