gpt4 book ai didi

Delphi:如何为 Action/MenuItem 分配向上箭头键盘快捷键,并使其保持实际用于导航列表控件 (ListBox/VTV)?

转载 作者:行者123 更新时间:2023-12-03 18:39:35 25 4
gpt4 key购买 nike

请帮助我:如何为操作或菜单项分配向上箭头键盘快捷键,并同时保持其实际用于导航列表控件(例如 ListBox/Virtual Treeview/other)?

谢谢!

最佳答案

你评论:

And how about the Winamp player? It has Volume Up/Volume Down features assigned to the up arrow key and down arrow key correspondingly.. Okay, if that impossible in Delphi, then ...



但这当然是可能的,但这样做并不是一个好主意,而且违反了 Windows 用户体验交互指南。

但是,如果您打算实现它,这就是方法。在包含操作组件的表单类中覆盖以下方法:
function IsShortCut(var Message: TWMKey): Boolean; override;

在其中,您可以防止 Up 和 Down 键触发它们作为快捷方式的操作:
function TWeirdForm.IsShortCut(var Message: TWMKey): Boolean;
begin
if (Message.CharCode in [VK_UP, VK_DOWN])
// insert test whether message needs to go to the focused control instead
and (...)
then begin
// insert calls to code that should be executed instead
Result := False;
exit;
end;
inherited;
end;

请注意,您还应该测试正确的移位状态,并检查您的代码是否不会破坏用户期望的任何其他窗口行为,例如使用箭头键移动窗口。

关于Delphi:如何为 Action/MenuItem 分配向上箭头键盘快捷键,并使其保持实际用于导航列表控件 (ListBox/VTV)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2176519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com