class PPCurses::ButtonPair

For grouping two buttons together, i.e. SUBMIT/CANCEL

Attributes

button1[RW]
button2[RW]
selected[RW]
selected_element[RW]

Public Class Methods

new(button1_label, button2_label) click to toggle source
# File lib/ppcurses/form/button.rb, line 64
def initialize(button1_label, button2_label)
  @button1 = Button.new(button1_label)
  @button2 = Button.new(button2_label)

  @selected_button = @button1

  @selected = false
end

Public Instance Methods

clear() click to toggle source
# File lib/ppcurses/form/button.rb, line 120
def clear
 # NOP
end
height() click to toggle source
# File lib/ppcurses/form/button.rb, line 78
def height
  2
end
key_down( key ) click to toggle source
# File lib/ppcurses/form/button.rb, line 86
def key_down( key )
  if key == KEY_RIGHT or key == KEY_LEFT
    @selected_button.selected=false

    if @selected_button == @button1
      @selected_button = @button2
    else
      @selected_button = @button1
    end

    @selected_button.selected=true
    return
  end

  @selected_button.key_down(key)

end
selected=(val) click to toggle source
# File lib/ppcurses/form/button.rb, line 73
def selected=(val)
  @selected_button.selected = val
  @selected=val
end
set_curs_pos(screen) click to toggle source
# File lib/ppcurses/form/button.rb, line 82
def set_curs_pos(screen)
  Curses.curs_set(INVISIBLE)
end
show(screen) click to toggle source
# File lib/ppcurses/form/button.rb, line 104
def show(screen)

  p = screen.cur_point
  p.y+=1
  screen.set_pos_by_point(p)


  @button1.show(screen)

  p.x += @button1.width + 2
  screen.set_pos_by_point(p)

  @button2.show(screen)

end