1. Computing

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

By

2 of 5

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

Another of the dialog methods in Shoes is the ask method. This method will display a simple dialog with an edit_line and a string of text. It can be used to ask for answers to simple questions, such as the one demonstrated in the example: What is your name?. Don't forget to store the string returned by the method in a variable for future use.

Shoes.app :width => 200, :height => 80 do
  button "Click me" do
    name = ask "What is your name?"
    @box.clear do
      para "Your name is ", name
    end
  end

  @box = stack
end
  1. About.com
  2. Computing
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Asking a Question

©2014 About.com. All rights reserved.