Method: CDK::BUTTONBOX#inject
- Defined in:
- lib/cdk/buttonbox.rb
#inject(input) ⇒ Object
This injects a single character into the widget.
151 152 153 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/cdk/buttonbox.rb', line 151 def inject(input) = 0 = @button_count - 1 pp_return = 1 ret = -1 complete = false # Set the exit type self.setExitType(0) unless @pre_process_func.nil? pp_return = @pre_process_func.call(:BUTTONBOX, self, @pre_process_data, input) end # Should we continue? if pp_return != 0 # Check for a key binding. if self.checkBind(:BUTTONBOX, input) complete = true else case input when Ncurses::KEY_LEFT, Ncurses::KEY_BTAB, Ncurses::KEY_BACKSPACE if @current_button - @rows < @current_button = else @current_button -= @rows end when Ncurses::KEY_RIGHT, CDK::KEY_TAB, ' '.ord if @current_button + @rows > @current_button = else @current_button += @rows end when Ncurses::KEY_UP if @current_button -1 < @current_button = else @current_button -= 1 end when Ncurses::KEY_DOWN if @current_button + 1 > @current_button = else @current_button += 1 end when CDK::REFRESH @screen.erase @screen.refresh when CDK::KEY_ESC self.setExitType(input) complete = true when Ncurses::ERR self.setExitType(input) complete = true when CDK::KEY_RETURN, Ncurses::KEY_ENTER self.setExitType(input) ret = @current_button complete = true end end if !complete && !(@post_process_func.nil?) @post_process_func.call(:BUTTONBOX, self, @post_process_data, input) end end unless complete self.drawButtons self.setExitType(0) end @result_data = ret return ret end |