| Issue 296: | Handle scroll wheel events separately from other mouse events | |
| 2 people starred this issue and may be notified of changes. | Back to list |
For example, with pygame as the window provider MOUSEBUTTON 4 and 5 (scroll up and down) could generate their own events with some code like this:
# mouse action
elif event.type in (pygame.MOUSEBUTTONDOWN,pygame.MOUSEBUTTONUP):
self._pygame_update_modifiers()
x, y = event.pos
btn = 'left'
if event.button == 3:
btn = 'right'
elif event.button == 2:
btn = 'middle'
eventname = 'on_mouse_down'
#Here are the two new cases to handle the scroll wheel
if event.button == 4:
btn = 'scroll_up'
eventname = 'on_scroll'
elif event.button == 5:
btn = 'scroll_down'
eventname = 'on_scroll'
if event.type == pygame.MOUSEBUTTONUP:
eventname = 'on_mouse_up'
self.dispatch_event(eventname, x, y, btn, self.modifiers)
This would be line 145 or so in pymt.ui.window.win_pygame. And the new on_scroll event needs to be defined and registered in __init__. I'm not sure how similar the code would be for those who use glut, but I imagine it's not too different.
Aug 15, 2010
Project Member
#1
txprog
Labels:
Type-Enhancement
|