Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jul 29, 2024
1 parent 63838d1 commit e22d703
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- `events.Enter` and `events.Leave` events now bubble. https://github.com/Textualize/textual/pull/4818
- Renamed `Widget.mouse_over` to `Widget.mouse_hover` https://github.com/Textualize/textual/pull/4818

## [0.74.0] - 2024-07-25

Expand Down
14 changes: 7 additions & 7 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def __init__(
has_focus: Reactive[bool] = Reactive(False, repaint=False)
"""Does this widget have focus? Read only."""

mouse_over: Reactive[bool] = Reactive(False, repaint=False)
mouse_hover: Reactive[bool] = Reactive(False, repaint=False)
"""Is the mouse over this widget? Read only."""

scroll_x: Reactive[float] = Reactive(0.0, repaint=False, layout=False)
Expand Down Expand Up @@ -3172,7 +3172,7 @@ def get_pseudo_classes(self) -> Iterable[str]:
Returns:
Names of the pseudo classes.
"""
if self.mouse_over:
if self.mouse_hover:
yield "hover"
if self.has_focus:
yield "focus"
Expand Down Expand Up @@ -3220,7 +3220,7 @@ def get_pseudo_class_state(self) -> PseudoClasses:

pseudo_classes = PseudoClasses(
enabled=not disabled,
hover=self.mouse_over,
hover=self.mouse_hover,
focus=self.has_focus,
)
return pseudo_classes
Expand Down Expand Up @@ -3264,7 +3264,7 @@ def post_render(self, renderable: RenderableType) -> ConsoleRenderable:

return renderable

def watch_mouse_over(self, value: bool) -> None:
def watch_mouse_hover(self, value: bool) -> None:
"""Update from CSS if mouse over state changes."""
if self._has_hover_style:
self._update_styles()
Expand All @@ -3277,7 +3277,7 @@ def watch_disabled(self, disabled: bool) -> None:
"""Update the styles of the widget and its children when disabled is toggled."""
from .app import ScreenStackError

if disabled and self.mouse_over and self.app.mouse_over is not None:
if disabled and self.mouse_hover and self.app.mouse_over is not None:
# Ensure widget gets a Leave if it is disabled while hovered
self._message_queue.put_nowait(events.Leave(self.app.mouse_over))
try:
Expand Down Expand Up @@ -3848,11 +3848,11 @@ def _on_mount(self, event: events.Mount) -> None:
self.show_horizontal_scrollbar = True

def _on_leave(self, event: events.Leave) -> None:
self.mouse_over = False
self.mouse_hover = False
self.hover_style = Style()

def _on_enter(self, event: events.Enter) -> None:
self.mouse_over = True
self.mouse_hover = True

def _on_focus(self, event: events.Focus) -> None:
self.has_focus = True
Expand Down
4 changes: 1 addition & 3 deletions tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_get_pseudo_class_state_parent_disabled():

def test_get_pseudo_class_state_hover():
widget = Widget()
widget.mouse_over = True
widget.mouse_hover = True
pseudo_classes = widget.get_pseudo_class_state()
assert pseudo_classes == PseudoClasses(enabled=True, focus=False, hover=True)

Expand Down Expand Up @@ -444,7 +444,6 @@ async def test_sort_children() -> None:
"""Test the sort_children method."""

class SortApp(App):

def compose(self) -> ComposeResult:
with Container(id="container"):
yield Label("three", id="l3")
Expand Down Expand Up @@ -481,7 +480,6 @@ async def test_sort_children_no_key() -> None:
"""Test sorting with no key."""

class SortApp(App):

def compose(self) -> ComposeResult:
with Container(id="container"):
yield Label("three", id="l3")
Expand Down

0 comments on commit e22d703

Please sign in to comment.