demo_input.py
changeset 77 fc1989059e19
parent 76 fa5301e58eca
equal deleted inserted replaced
76:fa5301e58eca 77:fc1989059e19
    17         self.editbox = EditBox(self.text)
    17         self.editbox = EditBox(self.text)
    18         scroll = ScrollView()
    18         scroll = ScrollView()
    19         scroll.add(self.editbox)
    19         scroll.add(self.editbox)
    20         self.top.add(scroll, halign='fill', valign='fill')
    20         self.top.add(scroll, halign='fill', valign='fill')
    21 
    21 
    22         self.editbox.add_handler('keypress', self.on_any_input)
    22         scroll.add_handler('keypress', self.on_any_input)
    23         self.editbox.add_handler('mousedown', self.on_any_input)
    23         scroll.add_handler('mousedown', self.on_any_input)
    24         self.editbox.add_handler('mouseup', self.on_any_input)
    24         scroll.add_handler('mouseup', self.on_any_input)
    25         self.editbox.add_handler('mousewheel', self.on_any_input)
    25         scroll.add_handler('mousewheel', self.on_any_input)
    26         self.editbox.add_handler('mousemove', self.on_any_input)
    26         scroll.add_handler('mousemove', self.on_any_input)
    27         self.editbox.add_handler('mousehover', self.on_any_input)
    27         scroll.add_handler('mousehover', self.on_any_input)
    28 
    28 
    29     def on_any_input(self, ev):
    29     def on_any_input(self, ev):
    30         if ev.event_name == 'keypress' and ev.keyname == 'escape':
    30         if ev.event_name == 'keypress' and ev.keyname == 'escape':
    31             self.terminate()
    31             self.terminate()
    32         line = ''.join((ev.event_name.ljust(10), ' : ', repr(ev)))
    32         line = ''.join((ev.event_name.ljust(10), ' : ', repr(ev)))