Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/guiguts/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ def add_to_project_dict() -> None:
"Do not show errors that appear more than this number of times",
)

def invoke_and_break(button: ttk.Button) -> str:
def invoke_and_break(evt: tk.Event, button: ttk.Button) -> str:
"""Invoke a button and return "break" to avoid further callbacks."""
# Don't override default text entry behavior for shortcuts
if evt.widget.winfo_class() in ("Entry", "TEntry", "TCombobox", "TSpinbox"):
return ""
button.invoke()
return "break"

Expand All @@ -166,7 +169,7 @@ def unbind_shifted_shortcut(key: str) -> None:
global_dict_button.grid(column=2, row=0, sticky="EW")
for accel in ("Cmd/Ctrl+a", "Cmd/Ctrl+A"):
_, key_event = process_accel(accel)
self.bind(key_event, lambda _: invoke_and_break(global_dict_button))
self.bind(key_event, lambda e: invoke_and_break(e, global_dict_button))
unbind_shifted_shortcut("a")
ToolTip(
global_dict_button,
Expand All @@ -180,7 +183,7 @@ def unbind_shifted_shortcut(key: str) -> None:
project_dict_button.grid(column=3, row=0, sticky="EW")
for accel in ("Cmd/Ctrl+p", "Cmd/Ctrl+P"):
_, key_event = process_accel(accel)
self.bind(key_event, lambda _: invoke_and_break(project_dict_button))
self.bind(key_event, lambda e: invoke_and_break(e, project_dict_button))
unbind_shifted_shortcut("p")
ToolTip(
project_dict_button,
Expand All @@ -194,7 +197,7 @@ def unbind_shifted_shortcut(key: str) -> None:
skip_button.grid(column=4, row=0, sticky="EW")
for accel in ("Cmd/Ctrl+s", "Cmd/Ctrl+S"):
_, key_event = process_accel(accel)
self.bind(key_event, lambda _: invoke_and_break(skip_button))
self.bind(key_event, lambda e: invoke_and_break(e, skip_button))
unbind_shifted_shortcut("s")
ToolTip(
skip_button,
Expand All @@ -208,7 +211,7 @@ def unbind_shifted_shortcut(key: str) -> None:
skip_all_button.grid(column=5, row=0, sticky="EW")
for accel in ("Cmd/Ctrl+i", "Cmd/Ctrl+I"):
_, key_event = process_accel(accel)
self.bind(key_event, lambda _: invoke_and_break(skip_all_button))
self.bind(key_event, lambda e: invoke_and_break(e, skip_all_button))
unbind_shifted_shortcut("i")
ToolTip(
skip_all_button,
Expand All @@ -220,7 +223,7 @@ def unbind_shifted_shortcut(key: str) -> None:
def select_invoke_and_break(evt: tk.Event, button: ttk.Button) -> str:
"""Select clicked message, then invoke given button and return "break"."""
self.select_entry_by_click(evt)
return invoke_and_break(button)
return invoke_and_break(evt, button)

mouse_bind(
self.text,
Expand Down
Loading