Glade Panel in Axis blocks arrow keys
- +Jan+
- Offline
- Senior Member
- Posts: 60
- Thank you received: 15
i made a glade side Panel for axis which works fine:
Here is my problem:
If you move the mouse into the side panel while moving the machine with the cursor keys, the machine continues moving even if you let go of the key. This can only be stopped by moving the mouse out of the panel and pressing the cursor keys again. Is there a way to avoid this dangerous behaviour?
I attached the whole config (a lot of copy and paste in it )
Please Log in or Create an account to join the conversation.
- +Jan+
- Offline
- Senior Member
- Posts: 60
- Thank you received: 15
Best Wishes
Jan
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
- Posts: 7762
- Thank you received: 2055
From the manual:
linuxcnc.org/docs/2.7/html/gui/gladevcp....key_handling_in_axis
I can't say if this behavior is new bug or not - I would bet that it is untested by linuxcnc builtin tests..
Are you using version 2.7 or master?
It would be helpful if someone could test 2.6 ,2.7 and master to see if the behavior changed.
Chris M
Please Log in or Create an account to join the conversation.
- +Jan+
- Offline
- Senior Member
- Posts: 60
- Thank you received: 15
I`ve did some further tests:
- Testing the behaviour with standard sample glade configs: Same Problem
- Embedding the glade panel as tab: Same Problem
- Updateding from 2.7.11 to 2.7.12 and then to 2.8 Master: Same Problem
The ESC key works in all configurations.
I`ve found an old topic with about a very similar problem (no solution): forum.linuxcnc.org/48-gladevcp/28429-gla...widgets?limitstart=0
I'm grateful for every idea how this problem could be solved.
Best wishes
Jan
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
- Posts: 7762
- Thank you received: 2055
looks like the keys you want are purposely ignored:
def keyboard_forward(window, forward):
""" XXX: Keyboard events forwardind
This is kind of hack needed to properly function inside Tk windows.
Gtk app will receive _all_ events, even not needed. So we have to forward
back things that left over after our widgets. Connect handlers _after_
all others and listen for key-presss and key-release events. If key is not
in ignore list - forward it to window id found in evironment.
"""
if not forward:
return
try:
forward = int(forward, 0)
except:
return
from Xlib.protocol import event
from Xlib import display, X
from Xlib.xobject import drawable
d = display.Display()
fw = drawable.Window(d.display, forward, 0)
ks = gtk.keysyms
ignore = [ ks.Tab, ks.Page_Up, ks.Page_Down
, ks.KP_Page_Up, ks.KP_Page_Down
, ks.Left, ks.Right, ks.Up, ks.Down
, ks.KP_Left, ks.KP_Right, ks.KP_Up, ks.KP_Down
, ks.bracketleft, ks.bracketright
]
def gtk2xlib(e, fw, g, type=None):
if type is None: type = e.type
if type == gtk.gdk.KEY_PRESS:
klass = event.KeyPress
elif type == gtk.gdk.KEY_RELEASE:
klass = event.KeyRelease
else:
return
kw = dict(window=fw, detail=e.hardware_keycode,
state=e.state & 0xff,
child=X.NONE, root=g._data['root'],
root_x=g._data['x'], root_y=g._data['y'],
event_x=0, event_y=0, same_screen=1)
return klass(time=e.time, **kw)
def forward(w, e, fw):
if e.keyval in ignore:
return
g = fw.get_geometry()
fe = gtk2xlib(e, fw, g)
if not fe: return
fw.send_event(fe)
window.connect_after("key-press-event", forward, fw)
window.connect("key-release-event", forward, fw)
window.add_events(gtk.gdk.KEY_PRESS_MASK)
window.add_events(gtk.gdk.KEY_RELEASE_MASK)
You could try changing this to see what happens.
Probably just want to not ignore the key release...
Chris M
Please Log in or Create an account to join the conversation.
- +Jan+
- Offline
- Senior Member
- Posts: 60
- Thank you received: 15
thanks a lot for this comment.
I found the file (on my machine the path is /usr/lib/pymodules/python2.7/gladevcp) and did some modifications.
I tried to remove the whole ignore section:
...
d = display.Display()
fw = drawable.Window(d.display, forward, 0)
ks = gtk.keysyms
ignore = [
]
def gtk2xlib(e, fw, g, type=None):
...
This leads to the following behaviour:
- Pushing the arrow key for x+ or x- , moving the mouse into the glade panel and then releasing the arrow key ==> release not detected
- Moving than with the mouse out of the glade panel and hitting the arrow key once again ==> release detected and machine stops
- Pushing x+ or x- arrow key, moving the mouse into the glade panel and then releasing the arrow key ==> RELEASE DETECTED!
- Then pushing the arrow key y+ or y-, moving the mouse into the glade panel and releasing the arrow key ==> release not detected
- Moving than with the mouse out of the glade panel and hitting the arrow key once again ==> release detected and machine stops
- Pushing y+ or y- arrow key, moving the mouse into the glade panel and then releasing the arrow key ==> RELEASE DETECTED!
- But then the release of x+ and x- is not detected anymore... and so on...
- For Z the behaviour is different: If I move the mouse into the glade panel the axis does not stop if I release the page up/down key, but the direction can be inverted while while the mouse is inside the panel (which is not possibile on the other axes).
For easier understanding I recorded the screen and logged the keys:
I do not need to move the axes while the mouse is inside the glade panel, but then the machine has to stop when I move into the glade panel. Any idea to reach this goal?
Best wishes
Jan
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
- Posts: 7762
- Thank you received: 2055
def forward(w, e, fw):
print 'key detected'
if e.keyval in ignore:
return
g = fw.get_geometry()
fe = gtk2xlib(e, fw, g)
if not fe: return
print 'event forwarded'
fw.send_event(fe)
If that is true then you could probably fix this problem by forwarding releases explicitly when linuxcnc is actively jogging.
One could use the python linuxcnc library for this.
But adding the print statements and doing your tests again would be the first step.
Chris M
Please Log in or Create an account to join the conversation.
- +Jan+
- Offline
- Senior Member
- Posts: 60
- Thank you received: 15
here is the result:
The detection seems to work.
If that is true then you could probably fix this problem by forwarding releases explicitly when linuxcnc is actively jogging.
One could use the python linuxcnc library for this.
I`m only good in copy and paste, so I would need some help for this
Thanks in advance
Jan
Please Log in or Create an account to join the conversation.
- Grotius
- Offline
- Platinum Member
- Posts: 2239
- Thank you received: 1958
I read your problem also.
Is there a way to avoid this dangerous behaviour?
I think you can fix this in glade, in your side panel behavior you can do that i think. In glade look at common / events for example.
I don't know all the item's, but i think it is possible in glade.
In the time of the Axis program design, the programmer's where thinking other way's.
So i think that's why this can happen.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
- Posts: 7762
- Thank you received: 2055
I'll see if I can piece something together for you to try.
Chris M
Please Log in or Create an account to join the conversation.