Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard jogging jumps between widgets #1084

Closed
genpfault opened this issue Jul 30, 2020 · 3 comments
Closed

Keyboard jogging jumps between widgets #1084

genpfault opened this issue Jul 30, 2020 · 3 comments

Comments

@genpfault
Copy link

genpfault commented Jul 30, 2020

@VanessaE in #691 (comment): This does not work anymore - you can click the circle and get a tiny little D-pad icon, but when you press one of the up or down cursor keys, the input focus jumps from one widget to another (depending on which key you pressed) until it lands on a text field such as the X/Y feed rate or extrude speed, where it sticks (at which point, up/down increments or decrements the value, and left/right move the text cursor in the field). Pressing right cursor while the focus is on the little D-pad does nothing at first, but holding it down for a second zooms in on the viewport. Left cursor sometimes moves the X axis, or zooms out, or jumps between widgets, or just does nothing.

And since it wasn't obvious to me initially which UI elements were being referenced, here's an annotated screenshot:

image

@genpfault
Copy link
Author

genpfault commented Jul 30, 2020

Moving the jog logic into the EVT_CHAR_HOOK handler works for me on Linux as of today's master (82f227d):

diff --git a/printrun/gui/xybuttons.py b/printrun/gui/xybuttons.py
index 5385171..46a2556 100644
--- a/printrun/gui/xybuttons.py
+++ b/printrun/gui/xybuttons.py
@@ -287,15 +287,13 @@ class XYButtons(BufferedCanvas):
     def OnTopLevelKey(self, evt):
         # Let user press escape on any control, and return focus here
         if evt.GetKeyCode() == wx.WXK_ESCAPE:
+            self.setKeypadIndex(-1)
             self.SetFocus()
-        evt.Skip()
 
-    def OnKey(self, evt):
-        if not self.enabled:
-            return
-        if self.keypad_idx >= 0:
+        if self.enabled and self.keypad_idx >= 0:
             if evt.GetKeyCode() == wx.WXK_TAB:
                 self.setKeypadIndex(self.cycleKeypadIndex())
+                return
             elif evt.GetKeyCode() == wx.WXK_UP:
                 self.quadrant = 1
             elif evt.GetKeyCode() == wx.WXK_DOWN:
@@ -312,14 +310,26 @@ class XYButtons(BufferedCanvas):
                 evt.Skip()
                 return
 
-            self.concentric = self.keypad_idx
+            self.concentric = self.keypad_idx + 1
             x, y, z = self.getMovement()
 
+            if evt.GetModifiers() == wx.MOD_CONTROL:
+                x, y, z = tuple([0.5 * i for i in (x, y, z)])
+            elif evt.GetModifiers() == wx.MOD_SHIFT:
+                x, y, z = tuple([2.0 * i for i in (x, y, z)])
+
             if x != 0 or y != 0 and self.moveCallback:
                 self.moveCallback(x, y)
             if z != 0 and self.zCallback:
                 self.zCallback(z)
-        elif evt.GetKeyCode() == wx.WXK_SPACE:
+            # swallow event
+            return
+        evt.Skip()
+
+    def OnKey(self, evt):
+        if not self.enabled:
+            return
+        if evt.GetKeyCode() == wx.WXK_SPACE:
             self.spacebarCallback()
 
     def OnMotion(self, event):

Bonus feature: hold down Control/Shift to halve/double the distance.

volconst added a commit to volconst/Printrun that referenced this issue Aug 22, 2020
Key bindings are not frame global, widget must be focused to react.
Draw focus rectangles for xy (except mini) and z jog widgets.
Keypad does not cycle, TAB exits jog widget after largest step.
Shift+TAB moves keypad backwards to compensate lack of cycling.
ESC key hides keypad icon so arrow keys do not cause jog movements.
Draw mouse highlight/shadow over keypad circle to hint it's clickable.
Holding Control/Shift keys during keypad moves scales them by 0.5 and 2
 as suggested in kliment#1084
Move scaling works for mouse clicks too, but only for xy jog control.
Z jog widget does not support move scaling.
@volconst
Copy link
Collaborator

@genpfault , Thanks for the code, I used some ideas and lines from it for the above commit.
You can check whether it works, it's already in rc7.

@genpfault
Copy link
Author

Looks good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants