Delphi 退格压力检测
只有当光标位于Timage组件上时,才有可能检测到像事件一样按下退格键吗?此快捷方式必须触发与TImage相关的专用图像处理。当鼠标进入或离开图像时,我只需启用/禁用按键检测事件 您只需要在表单上具有与TKeyEvent兼容的BackDetection函数:Delphi 退格压力检测,delphi,keypress,Delphi,Keypress,只有当光标位于Timage组件上时,才有可能检测到像事件一样按下退格键吗?此快捷方式必须触发与TImage相关的专用图像处理。当鼠标进入或离开图像时,我只需启用/禁用按键检测事件 您只需要在表单上具有与TKeyEvent兼容的BackDetection函数: procedure MyForm.BackDetection(Sender: TObject; var Key: word; Shift: TShiftState); begin if Key = VK_BACK then begin
procedure MyForm.BackDetection(Sender: TObject; var Key: word; Shift: TShiftState);
begin
if Key = VK_BACK then begin
...
... Your image-processing code
...
end;
end;
这确实要求KeyPreview为True
然后,当鼠标进入或离开图像时,您只需设置或禁用此事件
procedure MyForm.MyImageOnMouseEnter(Sender: TObject);
begin
OnKeyPress := BackDetection;
end;
procedure MyForm.MyImageOnMouseLeave(Sender: TObject);
begin
OnKeyPress := nil;
end;
我只想在鼠标进入或离开图像OnMouseEnter、onmouseeve时启用/禁用按键检测事件 您只需要在表单上具有与TKeyEvent兼容的BackDetection函数:
procedure MyForm.BackDetection(Sender: TObject; var Key: word; Shift: TShiftState);
begin
if Key = VK_BACK then begin
...
... Your image-processing code
...
end;
end;
这确实要求KeyPreview为True
然后,当鼠标进入或离开图像时,您只需设置或禁用此事件
procedure MyForm.MyImageOnMouseEnter(Sender: TObject);
begin
OnKeyPress := BackDetection;
end;
procedure MyForm.MyImageOnMouseLeave(Sender: TObject);
begin
OnKeyPress := nil;
end;
如果focus控件接受输入怎么办?如果focus控件接受输入怎么办?或者,可以始终设置按键事件并只检查鼠标位置。或者,可以始终设置按键事件并只检查鼠标位置。