Byte Player
Byte Player

Reputation: 57

Need Help figuring out why Firemonkey style for checkbox never displays the check

I am using Firemonkey in Delphi 11 and wanted to modify the checkbox to use a path rather than a text "X"

Using the original checkbox style as basis, I modified it so that it contained the following:

object TLayout
  StyleName = 'checkboxstyle'
  Align = Center
  Size.Width = 149.000000000000000000
  Size.Height = 30.000000000000000000
  Size.PlatformDefault = False
  TabOrder = 89
  object TLayout
    Align = Left
    Size.Width = 20.000000000000000000
    Size.Height = 30.000000000000000000
    Size.PlatformDefault = False
    object TRectangle
      StyleName = 'background'
      Align = Top
      Fill.Color = xFFC9C9C9
      Locked = True
      HitTest = False
      Padding.Bottom = 1.000000000000000000
      Margins.Left = 2.000000000000000000
      Margins.Top = 2.000000000000000000
      Margins.Right = 2.000000000000000000
      Position.X = 2.000000000000000000
      Position.Y = 2.000000000000000000
      Size.Width = 16.000000000000000000
      Size.Height = 16.000000000000000000
      Size.PlatformDefault = False
      Stroke.Color = xFF282727
      XRadius = 2.000000000000000000
      YRadius = 2.000000000000000000
      object TPath
        StyleName = 'checkmark'
        Align = Client
        Data.Path = {
          2A0000000000000000E0D8440000FF440100000000E0B5440000DC4401000000
          008093440060FE440200000000A0804400A00845020000000000614400601045
          0200000000C05F44006010450200000000405E44006010450200000000804C44
          00400C45020000000040384400200745010000000080134400E0FB4401000000
          004058440080D9440200000000007E4400A0C6440200000000808E4400A0B644
          0200000000808E4400E0B5440200000000808E440040B5440200000000C07D44
          0000A5440200000000C0574400009244010000000080124400C05E4401000000
          00803844008038440100000000405E44004012440100000000E0914400C05744
          020000000000A54400C07D44020000000040B54400808E440200000000E0B544
          00808E440200000000A0B64400808E440200000000A0C64400007E4402000000
          0080D944004058440100000000E0FB4400801344010000000020074500403844
          0200000000400C4500804C44020000000060104500405E440200000000601045
          00805F44020000000060104500C060440200000000A008450060804402000000
          0060FE44004093440100000000E0DB4400C0B544010000000000FF4400E0D844
          010000000000114500E0FB440100000000700745008007450100000000E0FB44
          000011450100000000E0D8440000FF440300000000E0D8440000FF44}
        Fill.Color = x00303030
        Margins.Left = 3.000000000000000000
        Margins.Top = 3.000000000000000000
        Margins.Right = 3.000000000000000000
        Margins.Bottom = 2.000000000000000000
        Size.Width = 10.000000000000000000
        Size.Height = 10.000000000000000000
        Size.PlatformDefault = False
        Stroke.Kind = None
        object TColorAnimation
          Duration = 0.100000001490116100
          PropertyName = 'Fill.Color'
          StartValue = x00303030
          StopValue = xFF303030
          Trigger = 'IsChecked=true'
        end
        object TColorAnimation
          Duration = 0.000099999997473788
          PropertyName = 'Fill.Color'
          StartValue = xFF303030
          StopValue = x00303030
          Trigger = 'IsChecked=false'
        end
      end
    end
  end
  object TText
    StyleName = 'text'
    Align = Client
    Locked = True
    HitTest = False
    Margins.Left = 1.000000000000000000
    Margins.Top = 2.000000000000000000
    Margins.Right = 1.000000000000000000
    Size.Width = 127.000000000000000000
    Size.Height = 28.000000000000000000
    Size.PlatformDefault = False
    Text = 'Text'
    TextSettings.FontColor = claSilver
    TextSettings.HorzAlign = Leading
    TextSettings.VertAlign = Leading
  end
end

However, when I apply this style to a checkbox, regardless as to the IsChecked setting the check never displays. Conversely, if I set its color to not have an alpha mask then then the check appears but doesn't go away if I uncheck the box.

Any insight as to what is going on, and how to fix this would be GREATLY appreaciated.

Upvotes: 1

Views: 259

Answers (1)

Michael Gardiner
Michael Gardiner

Reputation: 11

The problem lies in TCheckBox.TryValueIsChecked which uses TryStrToBool to pass a string boolean value. However 'true' and 'false' (used by style triggers) are not defined in the boolean strings. Adding the following code to your program's startup should work-around the problem until it's fixed.

var
  BoolLen: Integer;
begin
  BoolLen := Length(TrueBoolStrs);
  SetLength(TrueBoolStrs, BoolLen + 1);
  TrueBoolStrs[BoolLen] := 'true';
  BoolLen := Length(FalseBoolStrs);
  SetLength(FalseBoolStrs, BoolLen + 1);
  FalseBoolStrs[BoolLen] := 'false';
end;

Upvotes: 1

Related Questions