--- a/tuikit/menubar.py Wed Dec 26 01:00:31 2012 +0100
+++ b/tuikit/menubar.py Sat Dec 29 12:16:06 2012 +0100
@@ -29,33 +29,33 @@
item[1].menubar = self
i += len(item[0]) + 4
- def _handle_draw(self, screen, x, y):
- super()._handle_draw(screen, x, y)
- screen.pushcolor(self.bg)
+ def _handle_draw(self, ev):
+ super()._handle_draw(ev)
+ ev.driver.pushcolor(self.bg)
i = 0
for item in self.items:
if self.selected == item:
- screen.pushcolor(self.highlight)
- screen.puts(x + i, y, ' ' + item[0] + ' ')
- screen.popcolor()
+ ev.driver.pushcolor(self.highlight)
+ ev.driver.puts(ev.x + i, ev.y, ' ' + item[0] + ' ')
+ ev.driver.popcolor()
else:
- screen.puts(x + i, y, ' ' + item[0] + ' ')
+ ev.driver.puts(ev.x + i, ev.y, ' ' + item[0] + ' ')
i += len(item[0]) + 4
if i < self.width:
- screen.puts(x + i, y, ' ' * (self.width - i))
- screen.popcolor()
+ ev.driver.puts(ev.x + i, ev.y, ' ' * (self.width - i))
+ ev.driver.popcolor()
- def _handle_keypress(self, keyname, char):
- super()._handle_draw(keyname, char)
- if keyname == 'left':
+ def _handle_keypress(self, ev):
+ super()._handle_draw(ev)
+ if ev.keyname == 'left':
self.move_selected(-1)
- elif keyname == 'right':
+ elif ev.keyname == 'right':
self.move_selected(+1)
else:
if self.selected:
if isinstance(self.selected[1], Widget):
- self.selected[1].emit('keypress', keyname, char)
+ self.selected[1].emit('keypress', ev.keyname, ev.char)
def move_selected(self, offset):
@@ -68,25 +68,28 @@
def _handle_mousedown(self, ev):
super()._handle_mousedown(ev)
+ self._select_xy(ev.wx, ev.wy)
+
+ def _handle_mousemove(self, ev):
+ super()._handle_mousemove(ev)
+ self._select_xy(ev.wx, ev.wy)
+
+ def _select_xy(self, wx, wy):
i = 0
self.unselect()
for item in self.items:
w = len(item[0]) + 4
- if ev.wx >= i and ev.wx < i + w:
+ if wx >= i and wx < i + w:
self.select(item)
i += w
- def _handle_mousemove(self, ev):
- super()._handle_mousemove(ev)
- self.on_mousedown(ev)
-
- def _handle_unfocus(self, newfocus):
- super()._handle_unfocus()
- if self.selected and newfocus == self.selected[1]:
+ def _handle_unfocus(self, ev):
+ super()._handle_unfocus(ev)
+ if self.selected and ev.new == self.selected[1]:
return
self.unselect()
- def on_submenu_focus(self):
+ def on_submenu_focus(self, ev):
self.set_focus()
def select(self, item):