Skip to content

Commit

Permalink
Merge pull request #5404 from Textualize/footer-scroll
Browse files Browse the repository at this point in the history
Add ability to scroll Footer without holding shift
  • Loading branch information
willmcgugan authored Dec 18, 2024
2 parents 5889c48 + 3c7190a commit 2fb527b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/textual/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class MouseScrollDown(MouseEvent, bubble=True, verbose=True):
"""Sent when the mouse wheel is scrolled *down*.
- [X] Bubbles
- [ ] Verbose
- [X] Verbose
"""


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


Expand Down
15 changes: 15 additions & 0 deletions src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
Expand Down Expand Up @@ -249,6 +250,20 @@ async def bindings_changed(self, screen: Screen) -> None:
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)
Expand Down

0 comments on commit 2fb527b

Please sign in to comment.