mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
optimize link highlight
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Content-align
|
||||
|
||||
The `content-align` property allows you to align content _inside_ a widget.
|
||||
The `content-align` style aligns content _inside_ a widget.
|
||||
|
||||
You can specify the alignment of content on both the horizontal and vertical axes.
|
||||
|
||||
@@ -15,7 +15,7 @@ content-align: <HORIZONTAL> <VERTICAL>;
|
||||
#### `HORIZONTAL`
|
||||
|
||||
| Value | Description |
|
||||
|------------------|----------------------------------------------------|
|
||||
| ---------------- | -------------------------------------------------- |
|
||||
| `left` (default) | Align content on the left of the horizontal axis |
|
||||
| `center` | Align content in the center of the horizontal axis |
|
||||
| `right` | Align content on the right of the horizontal axis |
|
||||
@@ -23,7 +23,7 @@ content-align: <HORIZONTAL> <VERTICAL>;
|
||||
#### `VERTICAL`
|
||||
|
||||
| Value | Description |
|
||||
|-----------------|--------------------------------------------------|
|
||||
| --------------- | ------------------------------------------------ |
|
||||
| `top` (default) | Align content at the top of the vertical axis |
|
||||
| `middle` | Align content in the middle of the vertical axis |
|
||||
| `bottom` | Align content at the bottom of the vertical axis |
|
||||
|
||||
@@ -977,7 +977,7 @@ class App(Generic[ReturnType], DOMNode):
|
||||
finally:
|
||||
self.mouse_over = None
|
||||
else:
|
||||
if self.mouse_over != widget:
|
||||
if self.mouse_over is not widget:
|
||||
try:
|
||||
if self.mouse_over is not None:
|
||||
await self.mouse_over._forward_event(events.Leave(self))
|
||||
|
||||
@@ -147,7 +147,8 @@ class Widget(DOMNode):
|
||||
auto_links = Reactive(True)
|
||||
"""Widget will highlight links automatically."""
|
||||
|
||||
hover_style: Reactive[Style] = Reactive(Style)
|
||||
hover_style: Reactive[Style] = Reactive(Style, repaint=False)
|
||||
highlight_link_id: Reactive[str] = Reactive("")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -446,6 +447,12 @@ class Widget(DOMNode):
|
||||
|
||||
return height
|
||||
|
||||
def watch_hover_style(
|
||||
self, previous_hover_style: Style, hover_style: Style
|
||||
) -> None:
|
||||
if self.auto_links:
|
||||
self.highlight_link_id = hover_style.link_id
|
||||
|
||||
def watch_scroll_x(self, new_value: float) -> None:
|
||||
self.horizontal_scrollbar.position = int(new_value)
|
||||
self.refresh(layout=True)
|
||||
|
||||
Reference in New Issue
Block a user