Sha256: b6a365647d07cc9c93b8cd0240ee0862c65d099cadf65344921eb02007828726

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

# ----------------------------------------------------------------------------- #
#         File: actionmanager.rb
#  Description: a class that manages actions for a widget
#
#       Author: rkumar http://github.com/rkumar/rbcurse/
#         Date: 2012-01-4
#      License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
#  Last update: ,,L
# ----------------------------------------------------------------------------- #
#
# Maintains actions for a widget
module RubyCurses
  class ActionManager
    include Io
    attr_reader :actions

    def initialize #form, config={}, &block
      @actions = []
       #instance_eval &block if block_given?
    end
    def add_action act
      @actions << act
    end
    def remove_action act
      @actions.remove act
    end
    #
    # insert an item at given position (index)
    def insert_action pos, *val
      @actions[pos] = val
    end
    #def create_menuitem *args
      #PromptMenu.create_menuitem *args
    #end

    # popup the hist
    #
    def show_actions
      return if @actions.empty?
      list = @actions
      menu = PromptMenu.new self do |m|
      list.each { |e|
        m.add *e
      }
      end
      menu.display_new :title => 'Widget Menu (Press letter)'
    end
  end # class
end # mod RubyC

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbhex-core-1.1.0.alpha3 lib/rbhex/core/include/actionmanager.rb
rbhex-core-1.1.0.alpha2 lib/rbhex/core/include/actionmanager.rb
rbhex-core-1.1.0.alpha1 lib/rbhex/core/include/actionmanager.rb
rbhex-core-1.0.0 lib/rbhex/core/include/actionmanager.rb