Consistent cursor move sound
[naja.git] / naja / widgets / selector.py
index 5e563a645bbeedbfb22049ddeed20118f9dbb3cb..4479b72adf5236e532b1b0535127408341621a94 100644 (file)
@@ -1,8 +1,10 @@
 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
+from naja.sound import sound
 
 
 class SelectorWidget(Container):
@@ -22,14 +24,15 @@ class SelectorWidget(Container):
 
     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)
+                sound.play_sound('zoop.ogg', volume=0.05)
                 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)