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

Benoît Minisini gambas at ...1...
Tue Feb 17 18:41:14 CET 2009


> 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,

-- 
Benoît




More information about the User mailing list