Class: AskDialog
Instance Method Summary collapse
-
#initialize(shell, msg, args) ⇒ AskDialog
constructor
A new instance of AskDialog.
- #open ⇒ Object
Constructor Details
#initialize(shell, msg, args) ⇒ AskDialog
Returns a new instance of AskDialog.
83 84 85 86 |
# File 'lib/shoes/ruby.rb', line 83 def initialize shell, msg, args @shell, @msg, @args= shell, msg, args super shell end |
Instance Method Details
#open ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/shoes/ruby.rb', line 88 def open display = getParent.getDisplay icon = Swt::Image.new display, File.join(DIR, '../static/purple_shoes-icon.png') @shell.setImage icon @shell.setSize 300, 125 @shell.setText 'Purple Shoes asks:' label = Swt::Label.new @shell, Swt::SWT::NONE label.setText @msg label.setLocation 10, 10 label.pack text = Swt::Text.new @shell, Swt::SWT::BORDER | Swt::SWT::SINGLE text.setLocation 10, 30 text.setSize 270, 20 b = Swt::Button.new @shell, Swt::SWT::NULL b.setText 'OK' b.setLocation 180, 55 b.pack b.addSelectionListener{|e| @ret = text.getText; @shell.close} b = Swt::Button.new @shell, Swt::SWT::NULL b.setText 'CANCEL' b.setLocation 222, 55 b.pack b.addSelectionListener{|e| @ret = nil; @shell.close} @shell.open while !@shell.isDisposed do display.sleep unless display.readAndDispatch end @ret end |