Du könntest auch ein SubClassing (nennt man das so?) nutzen, sofern die Controls eine passende Stelle zum Überschreiben anbieten.
In Deiner Projektunit fügst Du in der uses-Liste an der letzten Stelle eine
Unit hinzu, in der Du die verwendeten Controls anpasst.
Zur Laufzeit werden die Änderungen dann wirksam.
Delphi-Quellcode:
unit MainForm;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Edit,
FMX.Effects, ssClientManager,
ssfControls;
// hinzufügen !!!
type
TForm1 =
class(TForm)
Edit1: TEdit;
Label1: TLabel;
...
Alle betroffenen Controls müsstest Du dann überschreiben...
Delphi-Quellcode:
unit ssfControls;
interface
uses
FMX.Edit, FMX.Controls, System.Classes;
type
TEdit =
class(FMX.Edit.TEdit)
private
MasterFlag: Boolean;
protected
procedure SetText(
const Value:
string);
override;
function HasSsfCtrl: Boolean;
virtual;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Painting;
override;
published
end;
TCheckBox =
class(FMX.Controls.TCheckBox)
private
MasterFlag: Boolean;
protected
function HasSsfCtrl: Boolean;
virtual;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Painting;
override;
published
end;
TSpinBox =
class(FMX.Edit.TSpinBox)
private
CreateFlag: Boolean;
MasterFlag: Boolean;
protected
procedure SetValue(
const AValue: Single);
override;
function HasSsfCtrl: Boolean;
virtual;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Painting;
override;
published
end;
implementation
uses
FMX.Types, ssClientManager, System.SysUtils;
{ TEdit }
constructor TEdit.Create(AOwner: TComponent);
begin
inherited;
end;
destructor TEdit.Destroy;
begin
inherited;
end;
function TEdit.HasSsfCtrl: Boolean;
var
FmxObj: TFmxObject;
begin
Result := False;
if Assigned(FChildren)
then
for FmxObj
in FChildren
do
begin
if FmxObj
is TssfCtrl
then
Exit(True);
end;
end;
procedure TEdit.Painting;
var
FmxObj: TFmxObject;
ssfCtrl: TssfCtrl;
begin
inherited;
if HasSsfCtrl
then
begin
for FmxObj
in FChildren
do
begin
if FmxObj
is TssfCtrl
then
begin
ssfCtrl := (FmxObj
as TssfCtrl);
if (MasterFlag)
or (ssfCtrl.AllowMaster)
then
begin
MasterFlag := False;
if ssfCtrl.OwnerPropName <> '
'
then
ssfCtrl.SetPropData
else
ssfCtrl.PropText := Text;
end
else if ssfCtrl.AllowSlave
then
begin
if ssfCtrl.IsValid
then
begin
if ssfCtrl.OwnerPropName <> '
'
then
ssfCtrl.GetPropData
else
Text := ssfCtrl.PropText;
end;
end;
end;
end;
end;
end;
procedure TEdit.SetText(
const Value:
string);
begin
if not(csLoading
in ComponentState)
then
MasterFlag := True;
inherited;
end;
...