[Gambas-user] Ask About Table View
Doriano Blengino
doriano.blengino at ...1909...
Thu Oct 2 08:25:37 CEST 2008
Stefano Palmeri ha scritto:
> Il mercoledì 1 ottobre 2008 22:57:51 Leo Sendra ha scritto:
>
>> Hello all... I have a problem in table view programming.
>>
>> As we know, we can edit table view by using an edit method. When I use this
>> method, it take me to a cell in a table view. The
>> problem is, when I press an ENTER I want to change setfocus to a
>> textbox (suppose that I have 2 components in a form. They are table
>> view and textbox). But, the fact, when I press an ENTER, the cursor
>> moves to other cell in a table view. How can I change my setfocus to a
>> textbox by pressing an ENTER key on my keyboard?? If it's not possible,
>> please give me some suggestion how to change a setfocus to textbox??
>>
>> And
>> also, I wonder when I use an edit method like this:
>> tableview1.edit(list), I always get an error message. The message is
>> "NULL OBJECT".
>> Actually, I have declared a "list" as a String[]. And
>> I also give a value to this variable. But.. I always get that message.
>> So, my question is: How can I use this kind of edit method??
>>
>> Please help me.... I really need the answer immediately.... Thank you.....
>>
>>
>>
> 1st question:
>
> PUBLIC SUB TableView1_KeyPress()
>
> IF Key.Code = Key.Return THEN TextBox1.SetFocus
> IF Key.Code = Key.Enter THEN TextBox1.SetFocus
>
> END
>
Stefano,
I think this example will not work while the tableview is in edit mode.
I had the same problem just a few days ago. A TableView in edit mode
does not raise keypress events because it is not focused; a textbox has
the focus instead, and nobody knows it ID to attach an observer to it
and get keypresses.
After thinking a lot, I have these ideas:
1) Perhaps a form_keypress event is raised, even if the tableview is in
edit mode. Must try, but I seem to remember that it does not work (but
it is easy and fast to try).
2) A hidden menu item, having "Enter" as its shortcut, will always work
and get fired. As there are two different keys to catch (Return and
Enter), then two different hidden menu items must be created.
3) This semi-hidden textbox, which tableview uses to enter edit mode,
should be child of the main form. One can try to "FOR EACH" the form
and obtain a handle to the hidden textbox, then attach an observer to it
and... blah blah blah.
4) May be the simplest and more correct. After the user presses enter in
tableview while edit is active, a "save data" event is fired. Store that
data, abort edit mode and do textbox1.setfocus().
About the second question, I have no idea; probably it is a bug in
gambas. If it is so, then the only solution is to create a normal "true"
combobox, position it over the tableview in the right place, setfocus
it, and hide it when it looses focus. A lot of work.
Regards,
Doriano Blengino
More information about the User
mailing list