退格键检测
Backspace press detection
是否有可能仅在光标位于 Timage 组件上时检测退格键按下(如事件)?此快捷方式必须触发与 TImage 相关的专用图像处理。
我只想 enable/disable 当鼠标进入或离开图像时(OnMouseEnter、OnMouseLeave),它们会检测按键事件。
你只需要在你的表单上有一个 BackDetection 函数(与 TKeyEvent 兼容):
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;
是否有可能仅在光标位于 Timage 组件上时检测退格键按下(如事件)?此快捷方式必须触发与 TImage 相关的专用图像处理。
我只想 enable/disable 当鼠标进入或离开图像时(OnMouseEnter、OnMouseLeave),它们会检测按键事件。
你只需要在你的表单上有一个 BackDetection 函数(与 TKeyEvent 兼容):
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;