Merge pull request #5404 from Textualize/footer-scroll

Add ability to scroll Footer without holding shift
This commit is contained in:
Will McGugan
2024-12-18 13:34:42 +00:00
committed by GitHub
3 changed files with 19 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
### Fixed
- Fixed `Pilot.click` not working with `times` parameter https://github.com/Textualize/textual/pull/5398
@@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The content of an `Input` will now only be automatically selected when the widget is focused by the user, not when the app itself has regained focus (similar to web browsers). https://github.com/Textualize/textual/pull/5379
- Updated `TextArea` and `Input` behavior when there is a selection and the user presses left or right https://github.com/Textualize/textual/pull/5400
- Footer can now be scrolled horizontally without holding `shift` https://github.com/Textualize/textual/pull/5404
## [1.0.0] - 2024-12-12

View File

@@ -539,7 +539,7 @@ class MouseScrollDown(MouseEvent, bubble=True, verbose=True):
"""Sent when the mouse wheel is scrolled *down*.
- [X] Bubbles
- [ ] Verbose
- [X] Verbose
"""
@@ -548,7 +548,7 @@ class MouseScrollUp(MouseEvent, bubble=True, verbose=True):
"""Sent when the mouse wheel is scrolled *up*.
- [X] Bubbles
- [ ] Verbose
- [X] Verbose
"""

View File

@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING
import rich.repr
from rich.text import Text
from textual import events
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import ScrollableContainer
@@ -249,6 +250,20 @@ class Footer(ScrollableContainer, can_focus=False, can_focus_children=False):
if self.is_attached and screen is self.screen:
await self.recompose()
def _on_mouse_scroll_down(self, event: events.MouseScrollDown) -> None:
if self.allow_horizontal_scroll:
self._clear_anchor()
if self._scroll_right_for_pointer(animate=True):
event.stop()
event.prevent_default()
def _on_mouse_scroll_up(self, event: events.MouseScrollUp) -> None:
if self.allow_horizontal_scroll:
self._clear_anchor()
if self._scroll_left_for_pointer(animate=True):
event.stop()
event.prevent_default()
def on_mount(self) -> None:
self.call_next(self.bindings_changed, self.screen)
self.screen.bindings_updated_signal.subscribe(self, self.bindings_changed)