2015-02-20 00:35:01 -05:00
|
|
|
Shoes.app(title: "GUI component interaction") do
|
2013-04-10 21:29:02 -07:00
|
|
|
stack do
|
2015-02-20 00:35:01 -05:00
|
|
|
textbox = edit_line
|
2013-04-10 21:29:02 -07:00
|
|
|
|
2015-02-20 00:35:01 -05:00
|
|
|
textbox.change do
|
|
|
|
|
textbox.text = textbox.text.gsub(/[^\d]/, '') and alert "Input must be a number!" if textbox.text !~ /^\d*$/
|
2013-04-10 21:29:02 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
flow do
|
|
|
|
|
button "Increment" do
|
2015-02-20 00:35:01 -05:00
|
|
|
textbox.text = textbox.text.to_i + 1
|
2013-04-10 21:29:02 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
button "Random" do
|
2015-02-20 00:35:01 -05:00
|
|
|
textbox.text = rand 5000 if confirm "Do you want a random number?"
|
2013-04-10 21:29:02 -07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|