Skip to content

Commit f1962d4

Browse files
committed
Update to pushbutton.py
2 parents bdc5eeb + 750c53c commit f1962d4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

v3/primitives/pushbutton.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ def release_func(self, func, args=()):
3838
self._ff = func
3939
self._fa = args
4040

41-
def double_func(self, func, args=()):
41+
def double_func(self, func=False, args=()):
4242
self._df = func
4343
self._da = args
44+
if self._dd:
45+
self._dd.stop()
46+
self._dd = Delay_ms(self._ddto) if func else False
4447

45-
def long_func(self, func, args=()):
48+
def long_func(self, func=False, args=()):
4649
self._lf = func
4750
self._la = args
51+
if self._ld:
52+
self._ld.stop()
53+
self._ld = Delay_ms(self._lf, self._la) if func else False
4854

4955
# Current non-debounced logical button state: True == pressed
5056
def rawstate(self):
@@ -61,10 +67,6 @@ def _ddto(self): # Doubleclick timeout: no doubleclick occurred
6167
launch(self._ff, self._fa)
6268

6369
async def buttoncheck(self):
64-
if self._lf: # Instantiate timers if funcs exist
65-
self._ld = Delay_ms(self._lf, self._la)
66-
if self._df:
67-
self._dd = Delay_ms(self._ddto)
6870
while True:
6971
state = self.rawstate()
7072
# State has changed: act on it now.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy