1. Computing
Send to a Friend via Email

Are You Sure You Want to Exit? and Other Dialog Methods

By

4 of 5

Asking for a Color
Are You Sure You Want to Exit? and Other Dialog Methods

Unlike the previous methods, asking for a color is not a straightforward action. How do you describe a color? Shoes provides a number of named colors, but users can't be expected to know these. To solve this problem, the ask_color method displays a color selection dialog. Again, be sure to store the color returned in a variable for future use.

Shoes.app :width => 200, :height => 80 do
  button "Change Color" do
    color = ask_color("What color?")
    background color
  end
end

©2014 About.com. All rights reserved.