Method: CDK::MENU#activate

Defined in:
lib/cdk/menu.rb

#activate(actions) ⇒ Object

This activates the CDK Menu



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/cdk/menu.rb', line 108

def activate(actions)
  ret = 0

  # Draw in the screen.
  @screen.refresh

  # Display the menu titles.
  self.draw(@box)

  # Highlight the current title and window.
  self.drawSubwin

  # If the input string is empty this is an interactive activate.
  if actions.nil? || actions.size == 0
    @input_window = @title_win[@current_title]

    # Start taking input from the keyboard.
    while true
      input = self.getch([])

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

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