Forum: wxRuby Triggering Label Edit in ListCtrl

Posted by Ryan P. L. (ryanp_l)
on 2012-07-03 00:04
Is there any way to trigger an item in a ListCtrl to have its label
edited? For example, I have a single column ListCtrl that shows a list
of values. There is a button that lets you add a new value to the list.
When you click it, it immediately adds a new item with the label "New
Value." As of right now, the user would need to click the item to begin
editing it's value. I would like to have it immediately start editing
the label on creation of the new value, so the user can begin typing
without using the mouse to click it.

Thanks in advance!
Posted by Fabio Petrucci (biospank)
on 2012-07-03 09:40
(Received via mailing list)
I normally use ListCtrl to list/report items without editing but looking 
at
the documentation you should be able to do editing with a combination of
http://wxruby.rubyforge.org/doc/listctrl.html#List...
http://wxruby.rubyforge.org/doc/listctrl.html#List...

set_item_state(0, Wx::LIST_STATE_SELECTED, Wx::LIST_STATE_SELECTED)

set_focus()

hope this help.

bio.
Posted by Ryan P. L. (ryanp_l)
on 2012-07-03 17:27
Fabio Petrucci wrote in post #1067139:
> I normally use ListCtrl to list/report items without editing but looking
> at
> the documentation you should be able to do editing with a combination of
> http://wxruby.rubyforge.org/doc/listctrl.html#List...
> http://wxruby.rubyforge.org/doc/listctrl.html#List...
>
> set_item_state(0, Wx::LIST_STATE_SELECTED, Wx::LIST_STATE_SELECTED)
>
> set_focus()
>
> hope this help.
>
> bio.

Awesome! I have no idea why I never saw the edit_label method, that is 
exactly what I was looking for. Thanks for the help.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.