The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Padre::Wx::Role::Context - Role for Wx objects that implement context menus

DESCRIPTION

METHODS

context_bind

    sub new {
        my $class = shift;
        my $self  = $class->SUPER::new(@_);
    
        $self->context_bind('my_menu');
    
        return $self;
    }
    
    sub my_menu {
        # Fill the menu here
    }

The context_bind method binds an context menu event to default menu creation and popup logic, and specifies the method that should be called to fill the context menu with the menu entries.

It takes a single optional parameter of the method to be called to fill the menu.

If no method is provided then the method context_menu will be bound to the context menu event by default.

context_popup

    $self->context_popup('context_menu');

The context_popup menu triggers the immediate display of the popup menu for the object. It takes a compulsory single parameter, which should be the method to be used to fill the menu with entries.

context_menu

The context_menu method is the default method called to fill a context menu with menu entries.

It should be overloaded in any class that uses the context menu role.

A minimalist default implementation is provided which will show a single meny entry to launch the About Padre dialog.

context_append_function

    $self->context_append_function(
        $menu,
        Wx::gettext('Do Something'),
        sub {
            # Do something
        },
    );

The context_append_function method adds a menu entry bound to an arbitrary function call.

The function will be passed the parent object ($self in the above example) and the event object.

context_append_method

    $self->context_append_method
        $menu,
        Wx::gettext('Do Something'),
        'my_method',
    );

The context_append_method method adds a mene entry bound to a named method on the object.

The method will be passed the event object.

context_append_action

    $self->context_append_action(
        $menu,
        'help.about',
    );

The context_append_action method adds a menu entry bound to execute a named action from Padre::Wx::ActionLibrary.

The menu entry created as a result of this call is functionally identical to a normal menu entry from the menu bar on the main window.

context_append_options

    $self->context_append_options(
        $menu,
        'main_functions_panel',
    );

The context_append_options method adds a group of several radio menu entries that allow changing a configuration preference immediately.

The current value of the configuration preference will be checked in the radio group for information purposes.

COPYRIGHT & LICENSE

Copyright 2008-2013 The Padre development team as listed in Padre.pm.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

The full text of the license can be found in the LICENSE file included with this module.