On Friday 27 May 2016 19:58:21 Krzysztof wrote:
> Hi Martin,
>
> I need assign tmenuitem.shortcut at runtime (DELETE key and CTRL+K).
> How to make it? shortcutty is WORD and values in msekeyboard are keyty
> enums. Surprisingly casting word(key_Delete) did the trick but what
> with CTRL+K? AND or OR with key_control and key_k doesn't work.
>
TMenuItem.ShortCut and ShortCut1 are combined values of keycode and 
shiftstate. There are also TMenuItem.ShortCuts and ShortCuts1 for multistep 
shortcuts. Setting ShortCut actually sets the first item of ShortCuts.

The shiftstate masks are defined in lib/common/kernel/msekeyboard.pas:
"
const
 key_modpad =                    $0800; //ored for shortcut in taction
 key_modshift =                  $2000;  
 key_modctrl =                   $4000;
 key_modshiftctrl =              $6000;
 key_modalt =                    $8000;
 key_modshiftalt =               $a000;
 key_modpadshift =               $2000 or key_modpad;  
 key_modpadctrl =                $4000 or key_modpad;
 key_modpadshiftctrl =           $6000 or key_modpad;
 key_modpadalt =                 $8000 or key_modpad;
 key_modpadshiftalt =            $a000 or key_modpad;
"
and lib/common/kernel/mseactions.pas:
"
const
 shift = ord(key_modshift);
 ctrl = ord(key_modctrl);
 alt = ord(key_modalt);
 pad = ord(key_modpad);
"
Git master 11b327d7a54a99cb9827852c6a4378f0f67a80a5 has EncodeShortcut() 
function in mseactions.pas for convenience.

> BTW: LCL TAction has Shortcut property. Am I right that MSE
> TCustomAction doesn't have it and I must set it in tmenuitem? This is
> not suggestion, I'm just wondering if I'm doing it right
>
TCustomAction is the base type for TNoGuiAction which can be used in 
applications without GUI by adding "msenogui" instead of "msegui" in "uses" 
of the program unit. Please use TAction instead which has shortcut and other 
additional GUI properties.

Martin

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to