Sha256: f406916bd776a01f7a2a8366433d9ffaf5ac6206d5241b994578de75dd202298
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# -*- encoding : utf-8 -*- module PPCurses PP_MIXED_STATE = -1 PP_OFF_STATE = 0 PP_ON_STATE = 1 SELECTED_CHAR = '✓' class MenuItem attr_accessor :title # Who to notify when menu is selected chosen? # The target should be a method selector, and attr_accessor :target attr_accessor :state attr_accessor :selectable def initialize( title ) @title = title @state = PP_OFF_STATE @selectable = false end def display_string if @state == PP_OFF_STATE return ' ' + @title end SELECTED_CHAR + ' ' + @title end def toggle_on_off_state if @state == PP_OFF_STATE @state = PP_ON_STATE return end if @state == PP_ON_STATE @state = PP_OFF_STATE end end def handle_key(key) if key == ' ' and @selectable toggle_on_off_state unless @target.nil? @target.call(self) end return true end if key == ENTER unless @target.nil? @target.call(self) end return true end false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ppcurses-0.0.23 | lib/ppcurses/menu/menu_item.rb |