Class: Wee::SingleSelectionDialog

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

Overview

class ConfirmDialog

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(items, caption = nil, selected_item = nil) ⇒ SingleSelectionDialog

Returns a new instance of SingleSelectionDialog.



82
83
84
85
86
# File 'lib/wee/dialog.rb', line 82

def initialize(items, caption=nil, selected_item=nil)
  super(caption)
  @items = items
  @selected_item = selected_item
end

Instance Attribute Details

#selected_itemObject

Returns the value of attribute selected_item.



80
81
82
# File 'lib/wee/dialog.rb', line 80

def selected_item
  @selected_item
end

Instance Method Details

#buttonsObject



96
97
98
# File 'lib/wee/dialog.rb', line 96

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

#cancelObject



104
105
106
# File 'lib/wee/dialog.rb', line 104

def cancel
  answer nil
end

#okObject



100
101
102
# File 'lib/wee/dialog.rb', line 100

def ok
  answer @selected_item
end

#render_body(r) ⇒ Object



92
93
94
# File 'lib/wee/dialog.rb', line 92

def render_body(r)
  r.select_list(@items).selected(@selected_item).callback_method(:selected_item=)
end

#state(s) ⇒ Object



88
89
90
# File 'lib/wee/dialog.rb', line 88

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