Commit 1b936c6d authored by sumpfralle's avatar sumpfralle

fixed handling of keyboard input to accept numbers and +/- of the keypad as well


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@659 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 22ab9aa3
...@@ -335,6 +335,7 @@ class ModelViewWindowGL: ...@@ -335,6 +335,7 @@ class ModelViewWindowGL:
try: try:
keyval = getattr(event, "keyval") keyval = getattr(event, "keyval")
get_state = getattr(event, "get_state") get_state = getattr(event, "get_state")
key_string = getattr(event, "string")
except AttributeError: except AttributeError:
return return
# define arrow keys and "vi"-like navigation keys # define arrow keys and "vi"-like navigation keys
...@@ -358,19 +359,19 @@ class ModelViewWindowGL: ...@@ -358,19 +359,19 @@ class ModelViewWindowGL:
return chr(value) return chr(value)
else: else:
return None return None
if get_char(keyval) and (get_char(keyval) in '1234567'): if key_string and (key_string in '1234567'):
names = ["reset", "front", "back", "left", "right", "top", "bottom"] names = ["reset", "front", "back", "left", "right", "top", "bottom"]
index = '1234567'.index(get_char(keyval)) index = '1234567'.index(key_string)
self.rotate_view(view=VIEWS[names[index]]) self.rotate_view(view=VIEWS[names[index]])
self._paint_ignore_busy() self._paint_ignore_busy()
elif get_char(keyval) in ('i', 'm', 's', 'p'): elif key_string in ('i', 'm', 's', 'p'):
if (chr(keyval) == 'i'): if key_string == 'i':
key = "view_light" key = "view_light"
elif (chr(keyval) == 'm'): elif key_string == 'm':
key = "view_polygon" key = "view_polygon"
elif (chr(keyval) == 's'): elif key_string == 's':
key = "view_shadow" key = "view_shadow"
elif (chr(keyval) == 'p'): elif key_string == 'p':
key = "view_perspective" key = "view_perspective"
else: else:
key = None key = None
...@@ -379,8 +380,8 @@ class ModelViewWindowGL: ...@@ -379,8 +380,8 @@ class ModelViewWindowGL:
# re-init gl settings # re-init gl settings
self.glsetup() self.glsetup()
self.paint() self.paint()
elif get_char(keyval) in ("+", "-"): elif key_string in ("+", "-"):
if chr(keyval) == "+": if key_string == "+":
scale = 0.8 scale = 0.8
else: else:
scale = 1.25 scale = 1.25
...@@ -410,7 +411,7 @@ class ModelViewWindowGL: ...@@ -410,7 +411,7 @@ class ModelViewWindowGL:
self._paint_ignore_busy() self._paint_ignore_busy()
else: else:
# see dir(gtk.keysyms) # see dir(gtk.keysyms)
#print "Key pressed: %s (%s)" % (chr(keyval), get_state()) #print "Key pressed: %s (%s)" % (keyval, get_state())
pass pass
def check_busy(func): def check_busy(func):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment