]>
Dogcows Code - chaz/openbox/blob - python/buttonmap.py
1 from input import Pointer
4 """Set your buttonmap. Functions in the button map should all take a single
5 argument, a Client object, except for functions for Action_Motion events,
6 who should take 2 arguments, a PointerData object and a Client object."""
7 global _press_map
, _release_map
, _click_map
, _doubleclick_map
, _motion_map
14 for button
, context
, action
, func
in map:
15 if (action
== Pointer
.Action_Press
):
16 _press_map
.append((button
, context
, func
))
18 if (action
== Pointer
.Action_Release
):
19 _release_map
.append((button
, context
, func
))
21 if (action
== Pointer
.Action_Click
):
22 _click_map
.append((button
, context
, func
))
24 if (action
== Pointer
.Action_DoubleClick
):
25 _doubleclick_map
.append((button
, context
, func
))
26 mapfunc
= doubleclick_run
27 if (action
== Pointer
.Action_Motion
):
28 _motion_map
.append((button
, context
, func
))
30 Pointer
.bind(button
, context
, action
, mapfunc
)
32 def press_run(ptrdata
, client
):
33 """Run a button press event through the buttonmap"""
34 button
= ptrdata
.button
35 context
= ptrdata
.context
36 for but
, cont
, func
in _press_map
:
37 if (but
== button
and cont
== context
):
40 def release_run(ptrdata
, client
):
41 """Run a button release event through the buttonmap"""
42 button
= ptrdata
.button
43 context
= ptrdata
.context
44 for but
, cont
, func
in _release_map
:
45 if (but
== button
and cont
== context
):
48 def click_run(ptrdata
, client
):
49 """Run a button click event through the buttonmap"""
50 button
= ptrdata
.button
51 context
= ptrdata
.context
52 for but
, cont
, func
in _click_map
:
53 if (but
== button
and cont
== context
):
56 def doubleclick_run(ptrdata
, client
):
57 """Run a button doubleclick event through the buttonmap"""
58 button
= ptrdata
.button
59 context
= ptrdata
.context
60 for but
, cont
, func
in _doubleclick_map
:
61 if (but
== button
and cont
== context
):
64 def motion_run(ptrdata
, client
):
65 """Run a pointer motion event through the buttonmap"""
66 button
= ptrdata
.button
67 context
= ptrdata
.context
68 for but
, cont
, func
in _motion_map
:
69 if (but
== button
and cont
== context
):
This page took 0.038843 seconds and 4 git commands to generate.