1Padre::Wx::Action(3)  User Contributed Perl Documentation Padre::Wx::Action(3)
2
3
4

NAME

6       Padre::Wx::Action - Padre Action Object
7

SYNOPSIS

9         my $action = Padre::Wx::Action->new(
10             name       => 'file.save',
11             label      => 'Save',
12             comment    => 'Saves the current file to disk',
13             icon       => '...',
14             shortcut   => 'Ctrl-S',
15             menu_event => sub { },
16         );
17

DESCRIPTION

19       This is the base class for the Padre Action API.
20

KEYS

22       Each module is constructed using a number of keys. While only the name
23       is technically required there are few reasons for actions which lack a
24       label or menu_event.
25
26       The keys are listed here in the order they usually appear.
27
28   name
29       Each action requires an unique name which is used to reference and call
30       it.
31
32       The name usually has the syntax
33
34         group.action
35
36       Both group and action should only contain \w+ chars.
37
38   label
39       Text which is shown in menus and allows the user to see what this
40       action does.
41
42       Remember to use Wx::gettext to make this translatable.
43
44   need_editor
45       This action should only be enabled/shown if there is a open editor
46       window with a (potentially unsaved) document in it.
47
48       The action may be called anyway even if there is no editor (all
49       documents closed), but it shouldn't.
50
51       Set to a value of 1 to use it.
52
53   need_file
54       This action should only be enabled/shown if the current document has a
55       file name (meaning there is a copy on disk which may be older than the
56       in-memory document).
57
58       The action may be called anyway even if there is no file name for the
59       current document, but it shouldn't.
60
61       Set to a value of 1 to use it.
62
63   need_modified
64       This action should only be enabled/shown if the current document has
65       either been modified after the last save or was never saved on disk at
66       all.
67
68       The action may be called anyway even if the file is up-to-date with the
69       in-memory document, but it shouldn't.
70
71       Set to a value of 1 to use it.
72
73   need_selection
74       This action should only be enabled/shown if there is some text selected
75       within the current document.
76
77       The action may be called anyway even if nothing is selected, but it
78       shouldn't.
79
80       Set to a value of 1 to use it.
81
82   need
83       Expected to contain a CODE reference which returns either true or
84       false.
85
86       If the code returns true, the action should be enabled/shown, otherwise
87       it shouldn't, usually because it won't make sense to use this action
88       without whatever_is_checked_by_the_code. (For example, UNDO can't be
89       used if there was no change which could be undone.)
90
91       The CODE receives a list of objects which should help with the
92       decision:
93
94         config      Contains the current configuration object
95         editor      The current editor object
96         document    The current document object
97         main        The main Wx object
98
99       A typical sub for handling would look like this:
100
101         need => sub {
102             my $current = shift;
103             my $editor  = $current->editor or return 0;
104             return $editor->CanUndo;
105         },
106
107       Use this with caution! As this function is called very often there are
108       few to no checks and if this isn't a CODE reference, Padre may crash at
109       all or get very slow if your CODE is inefficient and requires a lot of
110       processing time.
111
112   comment
113       A comment (longer than label) which could be used in lists. It should
114       contain a short description of what this action does.
115
116       Remember to use Wx::gettext to make this translatable.
117
118   icon
119       If there is an icon for this action, specify it here.
120
121   shortcut
122       The shortcut may be set by the user. This key sets the default shortcut
123       to be used if there is no user-defined value.
124
125   menu_event
126       This is expected to contain a CODE reference which does the job of this
127       action or an ARRAY reference of CODE references which are executed in
128       order.
129

METHODS

131   new
132       A default constructor for action objects.
133
135       Copyright 2008-2011 The Padre development team as listed in Padre.pm.
136
137       This program is free software; you can redistribute it and/or modify it
138       under the same terms as Perl itself.
139
140       The full text of the license can be found in the LICENSE file included
141       with this module.
142
143
144
145perl v5.30.1                      2020-01-30              Padre::Wx::Action(3)
Impressum