TMSFMXEdit Enabled/ReadOnly

I have created a descendant component based on the TMSFMXEdit.

eg.
type
  TMyEdit = class(TTMSFMXEdit)
  end;

I want to change (runtime) the FontColor and BackgroundColor if the Enabled property or ReadOnly property changes.
What's the best way to accomplish this ?

TIA.

The background cannot be changed, this is controlled on style level and is by default a bitmap that contains a white background image. For the font color you can use the following code when the enabled property changes:


uses
  UIConsts;

procedure TForm24.Button1Click(Sender: TObject);
begin
  e.Enabled := not e.Enabled;
end;

procedure TForm24.FormCreate(Sender: TObject);
begin
  e := TMyEdit.Create(Self);
  e.Parent := Self;
  e.Align := TAlignLayout.Center;
  e.Text := 'Hello World !';
  e.StyledSettings := e.StyledSettings - [TStyledSetting.FontColor];
  e.FontColor := claRed;
end;

{ TMyEdit }

procedure TMyEdit.SetEnabled(const Value: Boolean);
begin
  inherited;
  case Value of
    True: FontColor := claRed;
    False: FontColor := claBlue;
  end;
end;

Hi Pieter,


Thanks for the very quick response.

I can see how this can work with the Enabled property, because SetEnabled is a virtual method.
The SetReadOnly method however is not declared virtual in the TTMSFMXCustomEditEx class.

Any ideas how to make this work for the ReadOnly property as well ?

TIA

Hi, 


We have set the SetReadOnly method virtual and moved it to protected section, the next version will have this included.

Perfect...

I'll change this for now in my version of the sources as well.

Thanks again....