tags:

views:

31

answers:

1

Once a button is created in Shoes, is it possible to change the text? I've tried modifying the :text key in the button [email protected] confirms the text is changed--but the button still shows the original text.

+1  A: 

I haven't figured out how to change the text on the existing button. I suspect it just isn't supported as of yet. You could create a new button and replace the old one. Unfortunately, at least on Windows, removing a button mucks up all the click events. I haven't tried it on another platform, but maybe it'll work. Try something like this:

Shoes.app do
  para 'This is some text.'

  @btn = button 'a' do |btn|
    alert 'Hello, World!'
  end

  para 'Blah blah blah'

  button 'Change!' do |btn|
    old = @btn
    new_style = old.style.dup
    txt = new_style[:text].next!
    old.parent.before(old) do
      @btn = button txt, new_style
    end
    old.remove #This messes up the click events on Windows.
  end

end
Pesto