Ruby Shoes: how to replace button text with an image/icon

467 views Asked by At

I am trying to write a small Shoes app which contains a button. For example

Shoes.app :title => "Buttons" do 
  button_next = button "Next"
  button_prev = button "Previous"
end

Now, instead of the texts "Next" or "Previous" there should be icons on the buttons: a green arrow, showing to the right for the button_next and a green arrow showing to the left for the button_prev.

Of couse I already have the icons as .jpg-files but I can't figure out how to replace the text with the icons on the buttons.

For now I found out this way:

Shoes.app do 
  next_image = image "next.jpg", :width => 50, :height => 35
  next_image.click do 
    alert "Hey!"
  end
end

It works in the way that I can click the image and a new window, saying "Hey!" appears. But it is not ok, because I miss the typical button-appearance like changing of the color when hovering over it, or the press-down-effect when clicking on it.

So my question is: how can I create a real button in Ruby Shoes and replace the name of the button with an icon? Any ideas?

0

There are 0 answers