Class: Shoes::Dialog

Inherits:
Object
  • Object
show all
Defined in:
shoes-core/lib/shoes/dialog.rb

Instance Method Summary collapse

Constructor Details

#initializeDialog

Returns a new instance of Dialog


5
6
7
# File 'shoes-core/lib/shoes/dialog.rb', line 5

def initialize
  @gui = Shoes.backend::Dialog.new
end

Instance Method Details

#alert(msg = '') ⇒ Object


9
10
11
# File 'shoes-core/lib/shoes/dialog.rb', line 9

def alert(msg = '')
  @gui.alert msg
end

#ask(msg, args) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'shoes-core/lib/shoes/dialog.rb', line 21

def ask(msg, args)
  ask_me = Shoes.app(title: args[:title] || "Shoes asks:",
                     width: 300, height: 125,
                     modal: true) do
    stack do
      para msg, margin: 10

      @e = edit_line margin_left: 10,
                     width:       width - 20,
                     secret:      args[:secret]

      flow margin_top: 10 do
        button "OK", margin_left: 150 do
          @result = @e.text
          close
        end

        button "Cancel" do
          @result = nil
          close
        end
      end
    end

    def result
      @result ||= nil
    end
  end

  ask_me.wait_until_closed
  ask_me.result
end

#ask_color(title) ⇒ Object


54
55
56
# File 'shoes-core/lib/shoes/dialog.rb', line 54

def ask_color(title)
  @gui.ask_color title
end

#confirm(msg = '') ⇒ Object


13
14
15
# File 'shoes-core/lib/shoes/dialog.rb', line 13

def confirm(msg = '')
  @gui.confirm msg
end

#dialog_chooser(title, folder = false, style = :open) ⇒ Object


17
18
19
# File 'shoes-core/lib/shoes/dialog.rb', line 17

def dialog_chooser(title, folder = false, style = :open)
  @gui.dialog_chooser title, folder, style
end