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

Prima::KeySelector - key combination widget and routines

DESCRIPTION

The module provides a standard widget for selecting user-defined key combinations. The widget class allows import, export, and modification of key combinations. The module also provides a set of routines useful for the conversion of key combinations between various representations.

SYNOPSIS

my $ks = Prima::KeySelector-> create( );
$ks-> key( km::Alt | ord('X'));
print Prima::KeySelector::describe( $ks-> key );

API

Properties

key INTEGER

Selects a key combination in integer format. The format is described in "Hotkey" in Prima::Menu, and is a combination of the km::XXX key modifiers and is either a kb::XXX virtual key or a character code value.

The property allows almost, but not all possible combinations of key constants. Only the km::Ctrl, km::Alt, and km::Shift modifiers are allowed.

Methods

All methods must be called without the object as a first parameter.

describe KEY

Accepts KEY in integer format and returns a string description of the key combination in a human-readable format. Useful for supplying an accelerator text to a menu.

print Prima::KeySelector::describe( km::Shift|km::Ctrl|km::F10);
Ctrl+Shift+F10
export KEY

Accepts KEY in integer format and returns a string with a perl-evaluable expression, which after the evaluation resolves to the original KEY value. Useful for storing a key into text config files, where the value must be both human-readable and easily passed to a program.

print Prima::KeySelector::export( km::Shift|km::Ctrl|km::F10);
km::Shift|km::Ctrl|km::F10
shortcut KEY

Converts KEY from integer format to a string, acceptable by Prima::AbstractMenu input methods.

print Prima::KeySelector::shortcut( km::Ctrl|ord('X'));
^X
translate_codes KEY, [ USE_CTRL = 0 ]

Converts KEY in integer format to three integers in the format accepted by the "KeyDown" in Prima::Widget event: code, key, and modifier. USE_CTRL is only relevant when the KEY first byte ( KEY & 0xFF ) is between 1 and 26, which means that the key is a combination of an alpha key with the control key. If USE_CTRL is 1, the code result is unaltered and is in range 1 - 26. Otherwise, the code result is converted to the character code ( 1 to ord('A'), 2 to ord('B'), etc ).

AUTHOR

Dmitry Karasik, <dmitry@karasik.eu.org>.

SEE ALSO

Prima, Prima::Widget, Prima::Menu.