diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-26 01:20:37 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-26 01:20:37 +0200 |
commit | b68b4e8fd7e0769e6c33f68f6b6d9db190a41b54 (patch) | |
tree | 04b319313d9a199e09aa663cfc6febe0ad03e7f7 | |
parent | d8046b94a52262d1453104de2df138a952cb4548 (diff) | |
download | MusicSampler-b68b4e8fd7e0769e6c33f68f6b6d9db190a41b54.tar.gz MusicSampler-b68b4e8fd7e0769e6c33f68f6b6d9db190a41b54.tar.zst MusicSampler-b68b4e8fd7e0769e6c33f68f6b6d9db190a41b54.zip |
Add exit key
-rw-r--r-- | helpers/mapping.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py index 4a1cd98..66d860d 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py | |||
@@ -5,6 +5,7 @@ from kivy.core.window import Window | |||
5 | import threading | 5 | import threading |
6 | import pygame | 6 | import pygame |
7 | import yaml | 7 | import yaml |
8 | import sys | ||
8 | 9 | ||
9 | from .lock import * | 10 | from .lock import * |
10 | from .music_file import * | 11 | from .music_file import * |
@@ -29,8 +30,16 @@ class Mapping(RelativeLayout): | |||
29 | 30 | ||
30 | def _on_keyboard_down(self, keyboard, keycode, text, modifiers): | 31 | def _on_keyboard_down(self, keyboard, keycode, text, modifiers): |
31 | key = self.find_by_key_code(keycode) | 32 | key = self.find_by_key_code(keycode) |
32 | if key is not None: | 33 | if len(modifiers) == 0 and key is not None: |
33 | threading.Thread(name = "MSKeyAction", target=key.do_actions).start() | 34 | threading.Thread(name = "MSKeyAction", target=key.do_actions).start() |
35 | elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'): | ||
36 | for thread in threading.enumerate(): | ||
37 | if thread.getName()[0:2] != "MS": | ||
38 | continue | ||
39 | thread.join() | ||
40 | |||
41 | pygame.quit() | ||
42 | sys.exit() | ||
34 | return True | 43 | return True |
35 | 44 | ||
36 | def find_by_key_code(self, key_code): | 45 | def find_by_key_code(self, key_code): |