Class: Wee::TextInputDialog

Inherits:
FormDialog show all
Defined in:
lib/wee/dialog.rb

Overview

class SingleSelectionDialog

Direct Known Subclasses

TextAreaDialog

Constant Summary

Constants inherited from Component

Component::NO_CHILDREN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FormDialog

#render, #render_buttons, #render_caption, #render_form

Methods inherited from Component

#add_decoration, #children, #choose_from, #confirm, #decoration, #decoration=, depends, #each_decoration, #find_decoration, #inform, instanciate, #process_callbacks, #remove_decoration, #remove_decoration_if, #render

Methods inherited from Presenter

#process_callbacks, #render, #render!, #renderer_class

Constructor Details

#initialize(caption = nil, text = "", size = 50) ⇒ TextInputDialog

Returns a new instance of TextInputDialog.



112
113
114
115
116
# File 'lib/wee/dialog.rb', line 112

def initialize(caption=nil, text="", size=50)
  super(caption)
  @text = text
  @size = size
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



110
111
112
# File 'lib/wee/dialog.rb', line 110

def text
  @text
end

Instance Method Details

#buttonsObject



130
131
132
# File 'lib/wee/dialog.rb', line 130

def buttons
  [['Ok', nil, :ok, :ok], ['Cancel', nil, :cancel, :cancel]]
end

#cancelObject



138
139
140
# File 'lib/wee/dialog.rb', line 138

def cancel
  answer nil
end

#okObject



134
135
136
# File 'lib/wee/dialog.rb', line 134

def ok
  answer @text
end

#render_body(r) ⇒ Object



122
123
124
# File 'lib/wee/dialog.rb', line 122

def render_body(r)
  r.text_input.size(@size).callback_method(:set_text).value(@text || "")
end

#set_text(text) ⇒ Object



126
127
128
# File 'lib/wee/dialog.rb', line 126

def set_text(text)
  @text = text.strip
end

#state(s) ⇒ Object



118
119
120
# File 'lib/wee/dialog.rb', line 118

def state(s) super
  s.add_ivar(self, :@text)
end