pascal - 带有快捷键 BkSp 的全局 TAction
问题描述
我将 TAction 的 ShortCut 键设置为 BkSp(退格键)。我正在尝试像在网络浏览器中那样实现后退按钮,所以我需要在除编辑控件(TMemo、TEdit 等)之外的任何控件中调用 TAction。
一切都按预期工作,但退格键未发送到编辑控件(因此用户无法删除字符)。
OnExecute 看起来像:
if (Screen.ActiveControl is TCustomMemo) or (Screen.ActiveControl is TCustomEdit) then exit;
DoBack;
任何想法过去 BkSp 键 trought TAction 编辑控制(所有平台 Win、Mac、Linux)?
解决方案
解决方案很简单,基于 Andreas Rejbrand 的评论,与 Delphi 中的相同。
在 OnUpdate 上采取行动:
procedure TForm1.aBackUpdate(Sender: TObject);
begin
aBack.Enabled := not (Screen.ActiveControl is TCustomEdit);
end;
和 OnExecute 采取行动:
procedure TForm1.aBackExecute(Sender: TObject);
begin
DoBack;
end;
推荐阅读
- sas - SAS 阵列创建
- c# - 如何在 asp.net mvc 的弹出窗口中创建一个空表单?
- sql - 为每个 carID 选择最大值
- scala - 如何使用尾递归实现树遍历
- sql - Sql 计算的 Group By 语法可能性
- javascript - javascript - 通过非常长的选择优化循环
- ios - 我在哪里可以为我的 iOS 项目获取与 Appium 兼容的 iOS 应用程序文件?
- php - WooCommerce Webhooks JSON 解析使用 PHP 对象 - 数组
- html - CSS 动画在 HTA 中不起作用
- model-view-controller - Json将整数转换为浮点数