Method: CDK::SELECTION#activate

Defined in:
lib/cdk/selection.rb

#activate(actions) ⇒ Object

This actually manages the selection widget



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/cdk/selection.rb', line 154

def activate(actions)
  # Draw the selection list
  self.draw(@box)

  if actions.nil? || actions.size == 0
    while true
      self.fixCursorPosition
      input = self.getch([])

      # Inject the character into the widget.
      ret = self.inject(input)
      if @exit_type != :EARLY_EXIT
        return ret
      end
    end
  else
    # Inject each character one at a time.
    actions.each do |action|
      ret = self.inject(action)
      if @exit_type != :EARLY_EXIT
        return ret
      end
    end
  end

  # Set the exit type and return.
  self.setExitType(0)
  return 0
end