Skip to content

Commit 817a1b2

Browse files
committed
fix: bind numpad Enter in description field to insert newline
The Tk Text widget's default class binding inserts a newline on <Return> but not on <KP_Enter> (numpad Enter) on macOS. Add an explicit <KP_Enter> binding that inserts a newline at the cursor, returning "break" to prevent double-insertion on platforms where it may already be handled.
1 parent ae2b842 commit 817a1b2

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

python/src/task_stack/window.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ def _build_ui(self) -> None:
441441
self._desc_text.bind("<FocusIn>", self._on_desc_focus_in)
442442
self._desc_text.bind("<Escape>", self._on_desc_escape)
443443
self._desc_text.bind("<KeyRelease>", self._on_desc_key_release)
444+
# The Text widget's default class binding inserts a newline on <Return>
445+
# but not on <KP_Enter> (numpad Enter) on some platforms (notably
446+
# macOS), so bind it explicitly to match <Return> behaviour.
447+
self._desc_text.bind("<KP_Enter>", self._on_desc_kp_enter)
444448
self._desc_placeholder_active = False
445449
self._desc_frame.pack_forget()
446450

@@ -913,6 +917,12 @@ def _on_desc_key_release(self, _event: tk.Event) -> None:
913917
return
914918
self._highlight_links()
915919

920+
def _on_desc_kp_enter(self, _event: tk.Event) -> str:
921+
if self._desc_placeholder_active:
922+
return "break"
923+
self._desc_text.insert(tk.INSERT, "\n")
924+
return "break"
925+
916926
def _highlight_links(self) -> None:
917927
text_widget = self._desc_text
918928
text_widget.tag_remove("link", "1.0", tk.END)

0 commit comments

Comments
 (0)