das Event screen.onactivecontrolchange wird nicht gefeuert,
wenn der Focus von einem wincontrol zum nächsten geht.
Lediglich beim Öffnen und Schließen eines Formulars wird es aufgerufen...
(Unter Delphi funktioniert das problemlos)
Muss unter Lazarus evt. noch eine Eigenschaft gesetzt werden oder ist das ganz einfach ein Fehler von Lazarus ?
Beisp:
Code: Alles auswählen
procedure txyz.dosomething(sender : tobject);
begin // dosomething wird nicht aufgerufen
beep;
end;
//.....
constructor txyz.create;
begin screen.onactivecontrolchange := @dosomething;
end;
Es scheint tatsächlich ein Lazarus Bug zu sein.
Wenn analog zu Delphi die letzte Zeile in
customform.inc : tcustomform.setfocusedcontrol geändert wird,
funktionierts : s.u.:
Code: Alles auswählen
function TCustomForm.SetFocusedControl(Control: TWinControl): Boolean;
var
ParentForm: TCustomForm;
CurControl: TWinControl;
begin
Result := False;
if (Control<>nil)
and (csDestroying in Control.ComponentState) then exit;
if (Parent<>nil) then begin
// delegate to topmost form
ParentForm:=GetParentForm(Self);
if ParentForm<>nil then
ParentForm.SetFocusedControl(Control);
exit;
end;
// update FActiveControl
if (FDesigner = nil) and (not (csLoading in ComponentState)) then
begin
if Control <> Self then
FActiveControl := Control
else
FActiveControl := nil;
end;
// update Screen object
Screen.FActiveControl := Control;
if Control<>nil then begin
Screen.FActiveCustomForm := Self;
Screen.MoveFormToFocusFront(Self);
if Self is TForm then
Screen.FActiveForm := TForm(Self)
else
Screen.FActiveForm := nil;
[b] screen.UpdateLastActive; [/b]// <--- added analog Delphi !!
end;