[Gambas-user] How to know permanently the cursor coordinates in a gridview?
Simonart Dominique
simonart.dominique at ...11...
Wed Feb 25 03:51:02 CET 2009
Benoît Minisini a écrit :
>> Hi,
>> I've a main Gridview (grdGame) surrounded by 2 other grids, grdHdef on
>> top and grdVdef on left of grdGame
>>
>> When the mouse cursor is over the main grid, I want to highlight a
>> column of the top grid and a row of the left grid facing the cursor
>> position.
>> How to know at each instant where the cursor is, that is without action
>> on any button?
>> I cannot use Mouse.X/Y because there is no mouse event
>>
>> Thank for your help,
>>
>
> Yep. The problem is that mouse move are not always generated. It depends on
> the internal implementation of the widget in the toolkit.
>
> What you can do is enabling a timer at Enter event, and disabling it at Leave
> event. Ecah timer the timer is triggered, just use the Mouse.ScreenX and
> Mouse.ScreenY properties to calculate where the cursor is on the GridView.
>
> The right solution would be implementing a "Tracking" property in the Control
> class to tell Gambas that you want MouseMove events even if no mouse button is
> pressed.
>
> Regards,
>
Thanks Benoit,
I've now the thing working! I couldn't think about
Mouse.ScreenX/Y because I work with 2.8 version and the Help
menu show only Mouse.X/Y and nothing else.
In a first try, I used the Enter event to post a flag and
start a loop like this
WHILE myFlag
WAIT 0.2
...whatever
wend
and used the Leave event to annulate the flag, but it didn't
work (recursivity problem I think)
so I changed the loop to break as soon as the cursor get out
the Grid limits (this is exactly what the Leave event did I
think :) ) and all is runing fine!
I had another idea in mind, by using a DrawingArea with
transparency and nothing in it and place it over the grid,
so I could use the tracking caracteristic, but I would have
to manage the grid process myself, so I did not try it yet.
regards,
Dominique Simonart
More information about the User
mailing list