Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /lib64/perl5/vendor_perl/Prima/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/perl5/vendor_perl/Prima/examples/keyselector.pl
=pod

=head1 NAME

examples/keyselector.pl - Interactive key selection and storage

=head1 FEATURES

Contains an example how to use standard key selection and conversion
features of Prima::KeySelector. A typical program with interactively
configurable keys reflects the changes of key assignments in menu
hot-keys and initialization file. In the example, changes are stored
in ~/.prima/keyselector INI-file.

=cut

use strict;
use Prima qw(Application KeySelector IniFile );

my $w = Prima::MainWindow-> create(
		text => 'Key selector',
		packPropagate => 0,
		menuItems => [
			[ File => [
				['FileExit' => "~Exit and save changes" => '' , '@X', => sub { $_[0]-> close } ],
				['FileQuit' => "Exit and ~discard changes", '', km::Alt|km::Shift|ord('X') => sub {
					$_[0]-> {saveOnExit} = 0;
					$_[0]-> close;
				}],
			]],
			[ Edit => [
				[ 'EditApply'    => "~Apply changes", '', '^A' => sub {
					shift-> Editor-> apply;
				}],
				[ 'EditDefault'  => "~Restore to defaults" => sub {
					shift-> Editor-> reset_to_defaults;
				}],
			]],
			[],
			[ Help => sub { $::application-> open_help("file://$0") } ],
		],
		onClose => sub { $_[0]-> menu-> keys_save( $_[0]-> {iniFile}-> section('Options')) if $_[0]-> {saveOnExit}},
);
$w-> {saveOnExit} = 1;

$w-> {iniFile} = Prima::IniFile-> create(
	file => Prima::Utils::path('keyselector'),
);
$w-> menu-> keys_load($w-> {iniFile}-> section( 'Options'), 1); # 1 is because we're lazy and want menu accels to be autogenerated

$w-> insert( 'Prima::KeySelector::MenuEditor' =>
	name         => 'Editor',
	pack         => { expand => 1, fill => 'both'},
	menu         => $w-> menu,
);

run Prima;

Hry