-
Notifications
You must be signed in to change notification settings - Fork 0
/
Binding.py
59 lines (43 loc) · 1.35 KB
/
Binding.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pygame
from Constants import *
class Binding():
def __init__(self, key, *args):
self._key = key
self.args = []
for arg in args:
self.args.append(arg)
self.enable = True
def key(self):
return self._key
#overload this
def function(self):
pass
class ListboxUpBind(Binding):
def __init__(self, key, *args):
Binding.__init__(self, key, *args)
def function(self):
if self.args:
obj_name, gui_state = self.args
gui_state.get_obj(obj_name).select_next(DIR_UP)
class ListboxDownBind(Binding):
def __init__(self, key, *args):
Binding.__init__(self, key, *args)
def function(self):
if self.args:
obj_name, gui_state = self.args
gui_state.get_obj(obj_name).select_next(DIR_DOWN)
class ButtonEnter(Binding):
def __init__(self, key, *args):
Binding.__init__(self, key, *args)
def function(self):
if self.args:
bttn = self.args[0]
#simulate a button press
bttn.key_input(pygame.MOUSEBUTTONUP)
class SelectNextTxtboxBind(Binding):
def __init__(self, key, *args):
Binding.__init__(self, key, *args)
def function(self):
if self.args:
gui_state = self.args[0]
gui_state.focus_next_control(TXT_BOX)