Skip to content

Commit

Permalink
Ensure line numbers are updated (DistributedProofreaders#229)
Browse files Browse the repository at this point in the history
Where a key press was handled too early (perhaps keystrokes that
are bound to the class rather than the instance) it did not then
also trigger the KeyPress event binding that updates the line
numbers. Using KeyRelease instead works fine, and is the simplest
and safest fix IMO.
  • Loading branch information
windymilla authored May 2, 2024
1 parent c73eeee commit 1712b74
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/guiguts/maintext.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def __init__(self, parent: tk.Widget, root: tk.Tk, **kwargs: Any) -> None:
self.linenumbers = TextLineNumbers(self.frame, self)
self.linenumbers.grid(column=0, row=0, sticky="NSEW")
self.bind_event("<Configure>", self._on_change, add=True, force_break=False)
self.bind_event("<KeyPress>", self._on_change, add=True, force_break=False)
# Use KeyRelease not KeyPress since KeyPress might be caught earlier and not propagated to this point.
self.bind_event("<KeyRelease>", self._on_change, add=True, force_break=False)
self.numbers_need_updating = True

def hscroll_set(*args: Any) -> None:
Expand Down

0 comments on commit 1712b74

Please sign in to comment.