Moving text on a window

All,

I am new to WxRuby, and I am reading the online WxRuby Documentation for
help. I want to add a control to my application that can move text
between two text controls on a window. For example, let’s say that I
have a text/list control with 3 text strings in it, ‘one’, ‘two’, and
‘three’. I want to be able to highlight ‘one’, click a button, and have
‘one’ appear in another text/list control on the window, and the
original window should only have ‘two’ and ‘three’ displayed in it now.
I can elaborate if this is not clear. Thank you in advance for any
help.

  • Shelton

Jason S. wrote:

I am new to WxRuby, and I am reading the online WxRuby Documentation
for help. I want to add a control to my application that can move
text between two text controls on a window. For example, let’s say
that I have a text/list control with 3 text strings in it, ‘one’,
‘two’, and ‘three’. I want to be able to highlight ‘one’, click a
button, and have ‘one’ appear in another text/list control on the
window, and the original window should only have ‘two’ and ‘three’
displayed in it now. I can elaborate if this is not clear. Thank you
in advance for any help.

Exactly how to do this depends on the type of control you’re copying
from and to. Assuming you’re using Wx::ListBox, which is nice and
simple, something like (untested):

assuming the_button is the Wx::Button

evt_button(the_button) do

get the selected text from the original window

sel_text = list_1.string_selection

add it to the other window

list_2.append (sel_text)

delete the selection in the old window

list_1.delete( list_1.selection )
end

a

Thank you for your response, it was very helpful. I have another
question concerning this issue. Once I have appended the selections
from ‘list1’ to ‘list2’, is there some sort of ‘getValue’ method that
will return the contents of the ‘list2’ list box, maybe into an array?
I have used the ‘getValue’ method to get the value of a combo box, but
what is the method for a list box. Thanks in advance for any help.

  • Shelton> Date: Tue, 16 Dec 2008 16:15:51 +0000> From:
    [email protected]> To: [email protected]> Subject: Re:
    [wxruby-users] Moving text on a window> > Jason S. wrote:> > I am
    new to WxRuby, and I am reading the online WxRuby Documentation > > for
    help. I want to add a control to my application that can move > > text
    between two text controls on a window. For example, let’s say > > that I
    have a text/list control with 3 text strings in it, ‘one’, > > ‘two’,
    and ‘three’. I want to be able to highlight ‘one’, click a > > button,
    and have ‘one’ appear in another text/list control on the > > window,
    and the original window should only have ‘two’ and ‘three’ > > displayed
    in it now. I can elaborate if this is not clear. Thank you > > in
    advance for any help.> > Exactly how to do this depends on the type of
    control you’re copying > from and to. Assuming you’re using Wx::ListBox,
    which is nice and > simple, something like (untested):> > # assuming
    the_button is the Wx::Button> evt_button(the_button) do> # get the
    selected text from the original window> sel_text =
    list_1.string_selection> # add it to the other window> list_2.append
    (sel_text)> # delete the selection in the old window> list_1.delete(
    list_1.selection )> end> > > a>
    _______________________________________________> wxruby-users mailing
    list> [email protected]>
    http://rubyforge.org/mailman/listinfo/wxruby-users

Jason S. wrote:

Thank you for your response, it was very helpful. I have another
question concerning this issue. Once I have appended the selections
from ‘list1’ to ‘list2’, is there some sort of ‘getValue’ method that
will return the contents of the ‘list2’ list box, maybe into an array?
If you want every text item in the listbox:

listbox.map { | i | listbox.string(i) }

If you want the text for selected items only:

listbox.selections.map { | i | listbox.string(i) }

a