Clever Hotkey Debouncing in Sikuli
In your docs, I suggest you update the pattern for hotkey debouncing. The old pattern ends up creating a variable and an "IF" check for every single new hotkey added, and is somewhat tedious. I suggest using a clever python trick of function passing and lambdas. Here is a better pattern. With this pattern, to add a new hotkey, you simply add a function and addHotKey() and DONE:
doing = None
def do(command):
global doing
doing = command
running = True
def quitSikuli(e):
global running
popup(
running = False
def helloWorld():
popup("Hello World")
Env.addHotkey("x", KeyModifier.
Env.addHotkey("c", KeyModifier.
while running:
if doing:
doing()
doing = None
wait(1)
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Jonathan for more information if necessary.