[Gambas-user] How to populate a gridview from keyboard

Dominique SIMONART simonart.dominique at ...11...
Thu Feb 19 21:28:43 CET 2009


Benoît Minisini a écrit :
>> Hi everyone,
>>
>> it seemed so simple that I feel a bit stupid with that question, but...
>> I want to fill a gridview with text coming from the keyboard, as in a
>> crossword.
>> I think I've to deal with the keypress event and the key.text data, but
>> how can I identify the cell to fill. I cannot even see any cursor on my
>> grid.
>> I want not to use the mouse cursor because my fingers are on the
>> keyboard all the time. I wish to define the next cell with the cursor
>> keys only.
>>
>> Could someone give me a short sample or point me on the right direction?
>>
>> Thanks in advance for your help
>> Dominique Simonart
>>
>>     
>
> Just implement the cursor your self. Create a class named MyGridView that 
> inherits GridView. 
>
> In it, create an observer on yourself to catch the KeyPress event, and add two 
> class variables (let's name them $X and $Y) to store the cursor coordinates. 
>
> Catch the Data event too to define the background / foreground of the cell: 
> Color.SelectededBackground and Color.SelectedForeground for the current cell 
> (Row = $Y and Column = $X), nothing otherwise (the standard colors).
>
> Then each time you move the cursor, update the $X and $Y variables, and 
> refresh the old current cell and the new one.
>
> If you don't want to use the Data event, you must use the MyGridView[X, Y] 
> cell accessor.
>
> Regards,
>
>   
Hi,
I've implemented the Xcur, Ycur coordinates in a inherited class and
this is working now. In case this could be used as an example, I join
the little test (9.2K) here.
Now I've another question. It is not related with the subject, but it is
illustrated by the joined code, so I think I've to keep this thread open!

My new question is: I want to execute some code while the mouse cursor
is over a grid (the bottom right one in the joined piece). Note please
that no mouse buttons are involved here, so I can't work whith the
MouseMove event. The code don't concern the grid itself but the adjacent
ones. I can't either use the GotFocus/LostFocus events because the code
has to follow the mouse curso position as long the mouse cursor is over
the grid. I hope this is clear enough !

thanks for your help,
Dominique Simonart
Dominique Simonart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GridWithCursor.gz
Type: application/x-gzip
Size: 9471 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090219/4e05aee3/attachment.bin>


More information about the User mailing list