Board index » delphi » Understanding TEditActions...

Understanding TEditActions...

I have a form with 2 TEdit controls and a TSpeedButton. The button is linked
to a TEditCopy Action. I understand that when the button is clicked the
Action finds a target to act upon, which happens to be the ActiveControl at
the time of the click if such is a TCustomEdit. What I can't figure out  is
how the VCL does to enable the button as soon as I select any text on any of
the Edit controls. Does anybody know the execution sequence from the point
that text gets selected to the point that the button is enabled?

Thank you.
Luis Arenal.

 

Re:Understanding TEditActions...


Quote
> I have a form with 2 TEdit controls and a TSpeedButton. The button is linked
> to a TEditCopy Action. I understand that when the button is clicked the
> Action finds a target to act upon, which happens to be the ActiveControl at
> the time of the click if such is a TCustomEdit. What I can't figure out  is
> how the VCL does to enable the button as soon as I select any text on any of
> the Edit controls. Does anybody know the execution sequence from the point
> that text gets selected to the point that the button is enabled?

Magic, Luis, pure magic <g>. In fact it all hinges on the Application.Idle
method. This method is called everytime the message loop code has processed a
message and finds the message queue empty. This happens practically after each
mouse or key event, so very frequently while the user is working on the form.
Idle handles hints, sends CM_MOUSEENTER and CM_MOUSELEAVE messages, and it
calls a method called DoActionIdle. This method loops over all TCustomForms in
Screen.TCustomforms and calls the UpdateActions method of any that is visible
and enabled. UPdateAction calls InitiateAction (a method inherited from
TControl), then runs over all menu items and controls on the form and calls
their InitiateAction method.

procedure TControl.InitiateAction;
begin
  if ActionLink <> nil then ActionLink.Update;
end;

ActionLink is a property of TControl and refers to an TControlActionLink
object, which manages the connection to the Action the control/form/menuitem
may be linked to. It is created in the write method (SetAction) for the Action
property. Its Update method calls the associated Actions Update method.

There is now an astonishing amount of code executed from Application.Idle...

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads