From ce7c02ba8e2210b67f7370350f9cac8a83a1399e Mon Sep 17 00:00:00 2001
From: Darren Burns
Date: Sat, 12 Oct 2024 20:08:12 +0100
Subject: [PATCH] Add note on keymaps to home page, allow moving cursor in
confirmation dialog using arrow keys
---
docs/overrides/home.html | 5 ++++-
src/posting/widgets/confirmation.py | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/docs/overrides/home.html b/docs/overrides/home.html
index 869d363e..230491ab 100644
--- a/docs/overrides/home.html
+++ b/docs/overrides/home.html
@@ -1696,7 +1696,10 @@
Adjust the user interface to your liking through the configuration system or at runtime.
-
+
+
+ Customize keybindings to your liking using the keymap system.
+
diff --git a/src/posting/widgets/confirmation.py b/src/posting/widgets/confirmation.py
index 5a9225dc..e584965d 100644
--- a/src/posting/widgets/confirmation.py
+++ b/src/posting/widgets/confirmation.py
@@ -3,6 +3,7 @@
from typing import Literal
from textual import on
from textual.app import ComposeResult
+from textual.binding import Binding
from textual.containers import Horizontal, Vertical
from textual.screen import ModalScreen
from textual.widgets import Button, Static
@@ -26,6 +27,15 @@ class ConfirmationModal(ModalScreen[bool]):
}
"""
+ BINDINGS = [
+ Binding(
+ "left,right,up,down,h,j,k,l",
+ "move_focus",
+ "Navigate",
+ show=False,
+ )
+ ]
+
def __init__(
self,
message: str,
@@ -68,3 +78,7 @@ def confirm(self) -> None:
@on(Button.Pressed, "#cancel-button")
def cancel(self) -> None:
self.dismiss(False)
+
+ def action_move_focus(self) -> None:
+ # It's enough to just call focus_next here as there are only two buttons.
+ self.screen.focus_next()