Skip to content

Commit

Permalink
Pyglet backend emits an extra key press event when a 'text' key is pr…
Browse files Browse the repository at this point in the history
…essed

The first keypress event will have text set to empty string. If the
key being pressed represents a character, a second event is emitted
which has the right text, and key set to None.
  • Loading branch information
almarklein committed Aug 12, 2013
1 parent 2f2cf8a commit 1184c45
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vispy/app/backends/pyglet.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,21 @@ def on_key_press(self, key, modifiers):
# Emit
self._vispy_canvas.events.key_press(
key=self._processKey(key),
text=text,
text='', # Handlers that trigger on text wont see this event
modifiers=self._modifiers(modifiers),
)


def on_text(self, text):
# Typically this is called after on_key_press and before
# on_key_release
self._vispy_canvas.events.key_press(
key=None, # Handlers that trigger on key wont see this event
text=text,
modifiers=self._modifiers(),
)


def on_key_release(self, key, modifiers):
# Process modifiers
if key in ( pyglet.window.key.LCTRL, pyglet.window.key.RCTRL,
Expand Down

0 comments on commit 1184c45

Please sign in to comment.