mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-23 06:41:32 +03:00
Fix NoMatches crash if you tab to the color grid and then use arrows
This commit is contained in:
parent
d88885419c
commit
2aea62bff5
@ -1,6 +1,7 @@
|
||||
from typing import Any, Callable
|
||||
from textual import events, on
|
||||
from textual.containers import Container
|
||||
from textual.css.query import NoMatches
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button
|
||||
from textual.containers import Container
|
||||
@ -76,7 +77,10 @@ class ColorGrid(Container):
|
||||
|
||||
def _navigate_relative(self, delta: int) -> None:
|
||||
"""Navigate to a color relative to the currently focused color."""
|
||||
focused = self.query_one(".selected", Button)
|
||||
try:
|
||||
focused = self.query_one(".selected", Button)
|
||||
except NoMatches:
|
||||
return
|
||||
index = self._colors.index(self._color_by_button[focused])
|
||||
print(delta, (index % num_colors_per_row), num_colors_per_row)
|
||||
if delta == -1 and (index % num_colors_per_row) == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user