The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Games::Pandemic::Tk::Action - action item for main Games::Pandemic window

VERSION

version 0.7.0

SYNOPSIS

    my $action = Games::Pandemic::Tk::Action->new(
        window   => $mw,
        callback => $session->postback('event'),
    );
    $action->add_widget( $menu_entry );
    $action->add_widget( $button );
    $action->add_binding( '<Control-F>' );
    $action->enable;
    ...
    $action->disable;

DESCRIPTION

Menu entries are often also available in toolbars or other widgets. And sometimes, we want to enable or disable a given action, and this means having to update everything this action is allowed.

This module helps managing actions in a GUI: just create a new object, associate some widgets and bindings with add_widget() and then de/activate the whole action at once with enable() or disable().

The window and callback attributes are mandatory when calling the constructor.

METHODS

$action->add_widget( $widget );

Associate $widget with $action. Enable or disable it depending on current action status.

$action->rm_widget( $widget );

De-associate $widget with C$<action>.

$action->add_binding( $binding );

Associate $binding with $action. Enable or disable it depending on current action status. $binding is a regular binding, as defined by Tk::bind.

It is not possible to remove a binding from an action.

$action->enable;

Activate all associated widgets.

$action->disable;

De-activate all associated widgets.

AUTHOR

  Jerome Quelin

COPYRIGHT AND LICENSE

This software is Copyright (c) 2009 by Jerome Quelin.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007