Subject | Re: [IBO] Global GainFocusEvent |
---|---|
Author | Geoff Worboys |
Post date | 2002-01-01T02:29:15Z |
>> Then attach code to the OnReceiveFocus handler of the datalink, andThe OnReceiveFocus handler of TIB_DataLink is provided for controls
>> this handler will receive messages whenenver the focused datasource
>> changes.
> Exists something like OnLoseFocus ?
such as TIB_NavigationBar, so that they can dynamically alter the
datasource attached to the link.
The way I see it your implementation could go something like...
procedure TForm1.Form1Create( ... )
begin
FDataLink := TIB_DataLink.Create( Self );
FDataLink.OnReceiveFocus := ReceiveFocusEvent;
FDataLink.ReceiveFocus := true;
end;
procedure TForm1.Form1Destroy( ... )
begin
FDataLink.OnReceiveFocus := nil;
FreeAndNil( FDataLink );
end;
procedure TForm1.ReceiveFocusEvent( Sender: TIB_DataLink;
ADataSource: TIB_DataSource );
begin
// if datasource is changing
if ADataSource <> FDataLink.DataSource then
begin
if FDataLink.DataSource <> nil then
begin
// FDataLink.DataSource is losing focus
end;
// switch the linked datasource
FDataLink.DataSource := ADataSource;
if FDataLink.DataSource <> nil then
begin
// FDataLink.DataSource is gaining focus
end;
end;
end;
hth
--
Geoff Worboys
Telesis Computing