-2

I would like to know a way to verify if the focus of a component was activated by the mouse, if yes to execute a certain procedure in Delphi.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • If I don't have a mouse, can I not use your program? – David Heffernan Jun 19 '18 at 14:11
  • 3
    OnMouseDown event? I know that touch screens can generate these events too, but with the sparse amount of information that might or might not be relevant. – Dsm Jun 19 '18 at 14:40
  • `WM_SETFOCUS` message does not have the information about the source of the focus action. – Victoria Jun 19 '18 at 17:14
  • Your question seems to contradict itself. You mention "focus", yet seem to be interested in the mouse. Perhaps you should instead be concentrating on the "focus"? Or "hot"? Even then, as said by others, you can't rely on mouse movement all the time, because modern computers have touch screens and no actual mouse. – Jerry Dodge Jun 20 '18 at 02:36
  • Is this for VCL? – Sertac Akyuz Jun 20 '18 at 16:43

1 Answers1

0

you can use enter and exit event :

procedure TForm1.Edit1Exit(Sender: TObject); begin myProcedureRun1; end;

procedure TForm1.Edit1Enter(Sender: TObject); begin myProcedureRun2; end;

m.hatami
  • 603
  • 1
  • 7
  • 21