[wxruby-users] Moving text on a window
Alex Fenton
alex at pressure.to
Tue Dec 16 11:15:51 EST 2008
Jason Shelton 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
More information about the wxruby-users
mailing list