1

过去一周左右我一直在使用 Ruby Shoes,试图对它有一个很好的介绍。I just started using the list_box but I can't figure out how to code it out so that when a specific choice in a listbox is chosen, something else happens- I couldn't really understand what the manual was trying to do

x=1
list_box :items => ["Repair", "Request"]

在这种情况下,我希望在选择x时等于 1,在repair选择时等于 2 request。我该怎么办?

4

1 回答 1

2

此页面上找到。

你可以做类似的事情

Shoes.app do
  para "Choose a fruit:"
  list_box :items => ["Grapes", "Pears", "Apricots"],
           :width => 120,
           :choose => "Apricots" do |list|
    @fruit.text = list.text
  end
  @fruit = para "No fruit selected"
end

因此,您可以检查list对象并查看您可以访问哪些变量,然后根据所选选项执行您想要的操作。

于 2013-05-16T01:33:30.680 回答