-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path013_DoubleClick.py
More file actions
30 lines (24 loc) · 998 Bytes
/
013_DoubleClick.py
File metadata and controls
30 lines (24 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from time import time
# We used da emojis again, because we can :) oh, sorry: 😃
from emoji import emojize
# Panic buttons are panicky: https://en.wikipedia.org/wiki/Panic_button
panic = Actor('640px-hazard_warning_flasher_button')
# We plainly set our screen size to the size of our image
WIDTH = panic.width
HEIGHT = panic.height
# This is a simple and stupid double click implementation
# And we will define some global variables that will be visible in all our
# functions that handle mouse events (or any other functions, like draw())
lastClick = currentClick = 0
# Here we define the duration of the double click
double_click_duration = 0.5
def draw():
panic.draw()
def on_mouse_down(pos, button):
global lastClick
global double_click_duration
now = time()
print("You clicked the", button.name.lower(), "mouse button at", pos)
if now - lastClick <= double_click_duration:
print(emojize(':mouse: double click', use_aliases=True))
lastClick = time()