From f7a4384f075c53df1221916a0b0b153fe9d378e0 Mon Sep 17 00:00:00 2001 From: Galland Date: Sat, 24 May 2014 12:18:24 +0200 Subject: [PATCH] Bugfix releasing a key that was pressed over another window (i.e. Shift) Bug: Open a Nodebox window, go to another X window, press "Shift" key, focus again on the Nodebox window with the mouse and release "Shift" key. Nodebox exits with a ValueError exception because the key is not in the _keys list of pressed keys. Environment: Xubuntu Linux 14.04 (XFCE desktop) Solution: ignore ValueError exceptions when removing keys from the _keys list --- nodebox/graphics/context.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nodebox/graphics/context.py b/nodebox/graphics/context.py index 2c3b873..249df0b 100644 --- a/nodebox/graphics/context.py +++ b/nodebox/graphics/context.py @@ -3807,7 +3807,10 @@ def _on_key_release(self, keycode, modifiers): layer.on_key_release(self.key) self.on_key_release(self.key) self._keys.char = "" - self._keys.remove(keycode) + try: + self._keys.remove(keycode) + except ValueError: + pass self._keys.pressed = False def _on_text(self, text):