Skip to content
Snippets Groups Projects
Commit 0abef408 authored by q3k's avatar q3k
Browse files

py: allow disabling input repeat

parent 4b7f18c9
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ class Pressable:
def __init__(self, state: bool) -> None:
self._state = state
self._prev_state = state
self._repeat = RepeatSettings(400, 200)
self._repeat: Optional[RepeatSettings] = RepeatSettings(400, 200)
self._pressed_at: Optional[float] = None
self._repeating = False
......@@ -80,6 +80,21 @@ class Pressable:
self._ignoring = 0
def repeat_enable(self, first: int = 400, subsequent: int = 200) -> None:
"""
Enable key repeat functionality. Arguments are amount to wait in ms
until first repeat is emitted and until subsequent repeats are emitted.
Repeat is enabled by default on Pressables.
"""
self._repeat = RepeatSettings(first, subsequent)
def repeat_disable(self) -> None:
"""
Disable repeat functionality on this Pressable.
"""
self._repeat = None
def _update(self, ts: int, state: bool) -> None:
if self._ignoring > 0:
self._ignoring -= 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment