diff --git a/lib/rdialog.rb b/lib/rdialog.rb index 5b2b221..aa4430b 100644 --- a/lib/rdialog.rb +++ b/lib/rdialog.rb @@ -1,4 +1,3 @@ - # vim:ts=4:sw=4: # = rdialog - A dialog gem for Ruby # @@ -168,7 +167,7 @@ def checklist(text, items, height=0, width=0, listheight=0) puts command success = system(command) puts success - if success + if success && tmp.size > 0 selected_string = tmp.readline tmp.close! selected_string.slice!(0) @@ -511,11 +510,14 @@ def inputbox(text="Please enter some text", height=0, width=0, init="") # box has a Yes button and a No button, in which the user can # switch between by pressing the TAB key. - def yesno(text="Please enter some text", height=0, width=0) - command = option_string() + "--inputbox \"" + text.to_s + + def yesno(text="Please enter some text", height=0, width=0, value=true) + x = self.nocancel + self.nocancel = false + command = option_string() + (value ? "--yesno" : "--defaultno --yesno") + " \"" + text.to_s + "\" " + height.to_i.to_s + " " + width.to_i.to_s success = system(command) + self.nocancel = x return success end