Search code examples
delphifiremonkeydelphi-xe8

How can I keep my disabled controls opaque?


I've noticed that when I disable controls (controlName.enabled := false;) that they automatically become translucent.

Is there a way I can force them to stay opaque?

I've tried controlName.Opacity := 1; but that doesn't seem to do anything.

I've also tried embedding the control in a TLayout and then disabling the TLayout, but the translucency seems to be picked up by the embedded control.

[EDIT]

Here's an example of what I'm seeing In this case it's covering up a TLabel containing a big capitol F.

enter image description here


Solution

  • You can set the DisabledOpacity to 1.

    See example with two buttons added to a form :

    procedure TForm2.Button2Click(Sender: TObject);
    begin
      Button1.DisabledOpacity := 1;
      Button1.Enabled := not Button1.Enabled;
    end;
    

    This is a protected member so you have to override the control in your code.

     TButton = class(FMX.Stdctrls.TButton)
     //
      end;
    
      TForm2 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;