Sha256: 6b23869f49e8e61bec314dcf1fab885b36e860037822da447aaf74f91df9cac6

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'clevic/action_builder.rb'
require 'clevic/swing/action.rb'
require 'clevic/swing/extensions.rb'

require 'changes'

module Clevic

module ActionBuilder
  # Create a new separator and add a new separator.
  def separator
    Separator.new.tap do |action|
      add_action action
      collect_actions << action
    end
  end
  
  def create_action( &block )
    Action.new( self ).tap( &block )
  end
  
  # set up the code to be executed when an action is triggered,
  def action_method_or_block( action, options, &block )
    # connect the action to some code
    if options.has_key?( :method )
      action.handler do |event|
        action_triggered do
          send_args = [ options[:method], options.has_key?( :checkable ) ? action.menu_item.selected? : nil ].compact
          send( *send_args )
        end
      end
    else
      unless block.nil?
        # TODO not sure why triggered is outside here, but not in the method section
        action_triggered do
          action.handler do |event|
            yield( event )
          end
        end
      end
    end
  end
end

end # Clevic

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clevic-0.13.0.b9 lib/clevic/swing/action_builder.rb
clevic-0.13.0.b6 lib/clevic/swing/action_builder.rb
clevic-0.13.0.b5 lib/clevic/swing/action_builder.rb