GTK3 keyboard errors
Posted
#1
(In Topic #1436)
Regular

I asked this as a follow up question in my previous post but I figured I should start a new topic to get more eyes on it. I have a personal app where 100% of the user (me) input will be with a linux friendly remote I found on Amazon. Very similar to amazon's firestick remote. The remote control will be handled with keypress events. The code below I am trying to get some panels to slide in and out of view. It works great if I have it in a button. If I put that code in a keypress event I get "gb.gtk3: warning: calling the event loop during a keyboard event handler is ignored". The panels do move but I lose the sliding effect. I understand it is probably the Wait 0.1 that I have in there but if I remove the wait, then I lose my "animated" panel slide. Any suggestions on how to handle this? The remote control is essential for this project, if i can't use it then there is no point continuing because using a mouse would be silly for this.
Maybe there is something more I need to do with a keypress event?
Code (gambas)
- dypan1.Y = dypan1.Y - 1
- Wait 0.1
- dypan1.Y = dypan1.Y - 2
- Wait 0.1
- dypan1.Y = dypan1.Y - 3
- Wait 0.1
- dypan1.Y = dypan1.Y - 4
- Wait 0.1
- dypan1.Y = dypan1.Y - 5
- Wait 0.1
- dypan1.Y = dypan1.Y - 6
- Wait 0.1
- dypan1.Y = dypan1.Y - 7
- Wait 0.1
- dypan1.Y = dypan1.Y - 8
- Wait 0.1
- dypan1.Y = dypan1.Y - 9
- Wait 0.1
- dypan1.Y = dypan1.Y - 10
- Wait 0.1
- dypan1.Y = dypan1.Y - 11
- Wait 0.1
- dypan1.Y = dypan1.Y - 12
- Wait 0.1
- dypan1.Y = dypan1.Y - 13
- Wait 0.1
- dypan1.Y = dypan1.Y - 14
- Wait 0.1
- dypan1.Y = dypan1.Y - 15
- Wait 0.1
Posted
Regular

Posted
Regular

Posted
Guru

Wait will allow the event loop to run and you should not do that inside a key event.
Solutions…
Make a Timer and have the key event start the timer.
Code (gambas)
- $hTimer.Delay = 0
- $hTimer.Stop ' stop the timer
- ' use Wait as much as you like now as we are not in the key event any more.
Or…
Maybe try using Sleep instead of Wait
Sleep will pause the program like Wait But not let the event loop run. (but then your panel movement code might not work)
You will be wise to make a switch that cannot be enabled while already enabled, or keyboard repeat might make your code behave badly.
Posted
Regular

BruceSteers said
It's because you use Wait.
Wait will allow the event loop to run and you should not do that inside a key event.
Solutions…
Make a Timer and have the key event start the timer.Code (gambas)
$hTimer.Delay = 0 $hTimer.Stop ' stop the timer ' use Wait as much as you like now as we are not in the key event any more.
Or…
Maybe try using Sleep instead of Wait
Sleep will pause the program like Wait But not let the event loop run. (but then your panel movement code might not work)
You will be wise to make a switch that cannot be enabled while already enabled, or keyboard repeat might make your code behave badly.
Thanks Bruce. I figure it was the Wait but wasn't sure how to handle that. The sleep deosn't work either…you're right, the panel slide won't work with that either. The timer idea does seem to work though and I'll continue down that path, thanks for that. Yeah, I'll implement some enable/disable routines…that experiment project was just a crude example.
Posted
Guru

Posted
Regular

cogier said
I have got arrow keys working, as Bruce suggested, using a Timer. There is no need to stop and start the Timer as using Timer1.Trigger does the job. I have condensed your code considerably. Have a look here regarding the use of Quit to end programs.
slidingpanelsexperiment-CO-0.0.2.tar.gz
Thanks cogier! I knew there had to be a way to condense that y axis move code I just haven't had time to experiment with it.
1 guest and 0 members have just viewed this.


