|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 2 of 2 total|
|Notification on focus change of controls|
|Tue, Oct 6 2015 2:32 AM||Permanent Link|
I want to create a subclass of TBasicPanel where I have a method, that will be called when the
focus moves from one control on the panel to the next.
Do I have to catch OnEnter/OnExit of each control on my panel or is there a simpler way to do it in
the panel class directly?
|Tue, Oct 6 2015 11:20 AM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< I want to create a subclass of TBasicPanel where I have a method, that will be called when the focus moves from one control on the panel to the next. >>
Now is where you start to realize that creating a custom control has its advantages.
Doing things like this are trivial when the outer container control has complete control over the sub-controls (and creates them). With such a scenario, it's simply a matter of creating descendant classes for the child controls that forward all/some of their events on to their parent/owner control. The grid cells, for example, use this technique for mouse/touch events:
function TGridCell.DispatchEvent(ID: Integer; AElement: TElement): Boolean;
if ((ID >= cdMouseDown) and (ID <= cdMouseWheel) or
(ID >= cdTouchStart) and (ID <= cdTouchCancel)) then
The ForwardEvent method is a protected method of the base TInterfaceController class (ancestor of TControl that provides basic element-to-control functionality).
However, if you don't want to create descendant controls for the sub-controls, then you'll need to do the OnEnter/OnExit tracking instead.