[Gambas-user] Application_mousedown() + Application_keypress() ?

Lee McPherson leemcpherson at ...626...
Wed Sep 16 08:51:07 CEST 2009



Lee McPherson wrote:
> Ron_1st wrote:
>> On Monday 14 September 2009, Lee McPherson wrote:
>>
>>> Benoît Minisini wrote:
>>>
>>>>> I'm trying to get an application-wide mouse down event to 
>>>>> register.  I
>>>>> found that when I do a Form_mousedown() it only triggers when you 
>>>>> click
>>>>> on an empty part of the form, not when you're clicking on any type of
>>>>> control.  I'm looking for something that will trigger whenever you 
>>>>> hit
>>>>> the mouse button.  (My app is going to be full screen, so I don't 
>>>>> care
>>>>> if it works outside of the app window or not.)
>>>>>
>>>>> During my searching of the list archives, I found someone tried to 
>>>>> use
>>>>> Application_Keypress() as a way to get a key press while the app is
>>>>> running.  Well, I tried it and it doesn't work, nothing happens:
>>>>>
>>>>> Static Public Sub Application_Keypress()
>>>>>     Message.Info(Key.code)
>>>>> End
>>>>>
>>>>> I tried it on Gambas 2.8 and I even compiled Gambas 3.0 r2329 and 
>>>>> that
>>>>> didn't change anything.  I am using GTK only (Ubuntu).  Any ideas?
>>>>>
>>>>> Thanks,
>>>>> Lee
>>>>>
>>>>>             
>>>> There is no global pointer event handler, only 
>>>> Application_KeyPress(). But apparently it does not work with 
>>>> gb.gtk... Can you try with gb.qt to see if at least 
>>>> Application_KeyPress() is called? Note that this function must be 
>>>> defined in the startup class!
>>>>         
>>> Switching to gb.qt in gambas 3 works.  Haven't tried it in 2.8 yet, 
>>> but I don't want to use qt in any case.  Since there's no global 
>>> pointer event handler yet, it does not matter if you fix 
>>> applicaiton_keypress for gtk (for me at least).
>>> I would suggest a global pointer event handler as a feature if you 
>>> have the time.  The reason I wanted to use it was for a feedback 
>>> response when using a touchscreen.  Since there will be no pointer 
>>> on the screen (and no vibrate function like on a mobile phone), I 
>>> wanted to create a graphical response to touching (clicking) the 
>>> screen with your finger (a pointer).
>>> I suppose the only workaround to this is to create a procedure and 
>>> call the procedure for a mouse_down or mouse_up event for every 
>>> control on the form.
>>>
>>> Let me say that despite some of the drawbacks, this is the easiest 
>>> and most useful tool I've ever used to do programming.  Keep up the 
>>> good work!  When I get better at this I hope to contribute more myself.
>>>
>>> -Lee
>>>
>>>     
>>
>> take a look for 'xev', is a util in the x11 package.
>>
>>
>> Best regards,
>>
>> Ron_1st
>>   
> Thank you, I can see how this can be used as an alternative.  I'll be 
> experimenting...
>
> -Lee
Just an update to anyone following this thread:  xev is a great tool for 
testing your input devices when you click on the generated window.  
However, when you attach xev to an existing window using its window ID 
(found with xwininfo), it doesn't work the same way.  The log 
information does not contain button clicks for some reason.  It also 
doesn't work on a console window at all unless you're dragging it or 
leaving it (that was weird to me).  Attached to my half-finished gambas 
program, it would not record mouse clicks.  Oh well...

Other avenues I followed:  there is a program written in python called 
pykeylogger which is a key and mouse event logger.  I was tempted to use 
that in some fashion.  However, as of Xorg version 1.6.0, it is 
currently broken because of something to do with broken records in 
Xorg... ?  I don't know exactly what the problem is. But this may be 
feasible later on.

I found a program called "mev" which seems to get mouse clicks, but it 
seems half-broken and I couldn't get it to run as a process without 
being killed immediately.  When you run it on the command line it 
returns the command line as if the program is finished.  However, if you 
then click on the terminal window, some characters appear.  I ditched 
the attempt after a while.

Finally, I attempted to get data directly from /dev/input/mice.  
However, my mouse now goes to /dev/input/event3, but no mouse events can 
be recorded there (sudo cat /dev/input/event3).  Apparently, all the 
keyboard and mouse drivers use evdev now and lock out anything else from 
seeing signals from these input devices.  Sure enough, when I'm 
completely logged out of Xorg, I can see a steady stream of data using 
"sudo xxd /dev/input/event3" when I touch the touchpad.

If anyone else has ideas, I'd be glad to hear them.  However, this isn't 
critical to my app and I don't want to make this too time consuming.  
Ugh, I already wasted enough...

-Lee





More information about the User mailing list