++ed by:
16 non-PAUSE users
Author image Peter Lavender
and 46 contributors


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




    sub new {
        my $class = shift;
        my $self  = $class->SUPER::new(@_);
        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.



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.


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.


        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.


        Wx::gettext('Do Something'),

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.



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.



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 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.