Skip to content

Commit

Permalink
hover effects
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 22, 2024
1 parent 6c63918 commit 0ce8988
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,11 @@ def __init__(
self._previous_inline_height: int | None = None
"""Size of previous inline update."""

self._paused_hover_effects: bool = False
"""Have the hover effects been paused?"""

self._hover_effects_timer: Timer | None = None

if self.ENABLE_COMMAND_PALETTE:
for _key, binding in self._bindings:
if binding.action in {"command_palette", "app.command_palette"}:
Expand Down Expand Up @@ -2693,12 +2698,28 @@ def set_focus(self, widget: Widget | None, scroll_visible: bool = True) -> None:
"""
self.screen.set_focus(widget, scroll_visible)

def _pause_hover_effects(self):
self._paused_hover_effects = True

def _resume_hover_effects(self):
if self._paused_hover_effects:
self._paused_hover_effects = False
try:
widget, _ = self.screen.get_widget_at(*self.mouse_position)
except NoWidget:
pass
else:
if widget is not self.mouse_over:
self._set_mouse_over(widget)

def _set_mouse_over(self, widget: Widget | None) -> None:
"""Called when the mouse is over another widget.
Args:
widget: Widget under mouse, or None for no widgets.
"""
if self._paused_hover_effects:
return
if widget is None:
if self.mouse_over is not None:
try:
Expand Down

0 comments on commit 0ce8988

Please sign in to comment.