import pygame.locals as pgl
+from naja.constants import KEYS
from naja.widgets.base import Container
from naja.resources import resources
from naja.resources.mutators import EIGHT_BIT, R270
def handle_event(self, ev):
if ev.type == pgl.KEYDOWN:
- if ev.key in (pgl.K_DOWN, pgl.K_UP):
- if ev.key == pgl.K_DOWN:
+ if ev.key in KEYS.UP + KEYS.DOWN:
+ if ev.key in KEYS.DOWN:
self.position += 1
else:
self.position -= 1
self.position %= len(self.widgets)
return True
- elif ev.key == pgl.K_RETURN:
+ elif ev.key in KEYS.SELECT:
return self.widgets[self.position].callback('click')
return super(SelectorWidget, self).handle_event(ev)