Skip to content

Commit e22d703

Browse files
committed
rename
1 parent 63838d1 commit e22d703

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
### Changed
1616

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

1920
## [0.74.0] - 2024-07-25
2021

src/textual/widget.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def __init__(
428428
has_focus: Reactive[bool] = Reactive(False, repaint=False)
429429
"""Does this widget have focus? Read only."""
430430

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

434434
scroll_x: Reactive[float] = Reactive(0.0, repaint=False, layout=False)
@@ -3172,7 +3172,7 @@ def get_pseudo_classes(self) -> Iterable[str]:
31723172
Returns:
31733173
Names of the pseudo classes.
31743174
"""
3175-
if self.mouse_over:
3175+
if self.mouse_hover:
31763176
yield "hover"
31773177
if self.has_focus:
31783178
yield "focus"
@@ -3220,7 +3220,7 @@ def get_pseudo_class_state(self) -> PseudoClasses:
32203220

32213221
pseudo_classes = PseudoClasses(
32223222
enabled=not disabled,
3223-
hover=self.mouse_over,
3223+
hover=self.mouse_hover,
32243224
focus=self.has_focus,
32253225
)
32263226
return pseudo_classes
@@ -3264,7 +3264,7 @@ def post_render(self, renderable: RenderableType) -> ConsoleRenderable:
32643264

32653265
return renderable
32663266

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

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

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

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

38573857
def _on_focus(self, event: events.Focus) -> None:
38583858
self.has_focus = True

tests/test_widget.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_get_pseudo_class_state_parent_disabled():
204204

205205
def test_get_pseudo_class_state_hover():
206206
widget = Widget()
207-
widget.mouse_over = True
207+
widget.mouse_hover = True
208208
pseudo_classes = widget.get_pseudo_class_state()
209209
assert pseudo_classes == PseudoClasses(enabled=True, focus=False, hover=True)
210210

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

446446
class SortApp(App):
447-
448447
def compose(self) -> ComposeResult:
449448
with Container(id="container"):
450449
yield Label("three", id="l3")
@@ -481,7 +480,6 @@ async def test_sort_children_no_key() -> None:
481480
"""Test sorting with no key."""
482481

483482
class SortApp(App):
484-
485483
def compose(self) -> ComposeResult:
486484
with Container(id="container"):
487485
yield Label("three", id="l3")

0 commit comments

Comments
 (0)