Jump to content
Sign in to follow this  
Dave Nottage

TBitmap published property

Recommended Posts

I have an FMX component with a published TBitmap property, but the property is not being read when the component is loaded (the other properties are).

 

Holger Flick's article suggests that it is possible: https://flixengineering.com/archives/166

 

Is there something special I need to do to make it work? This is what the declaration looks like:

 

  TCustomNativeDoodad = class(TPresentedControl)
  private
    function GetMaxImage: TBitmap;
    function GetMinImage: TBitmap;
    function GetModel: TCustomNativeDoodadModel; overload;
    function GetValue: Single;
    procedure SetValue(const Value: Single);
    function GetOnValueChange: TNotifyEvent;
    function GetOrientation: TDoodadOrientation;
    procedure SetMaxImage(const Value: TBitmap);
    procedure SetMinImage(const Value: TBitmap);
    procedure SetOnValueChange(const Value: TNotifyEvent);
    procedure SetOrientation(const Value: TDoodadOrientation);
  protected
    function DefineModelClass: TDataModelClass; override;
    function RecommendSize(const AWishedSize: TSizeF): TSizeF; override;
  public
    constructor Create(AOwner: TComponent); override;
    property MaxImage: TBitmap read GetMaxImage write SetMaxImage;
    property MinImage: TBitmap read GetMinImage write SetMinImage;
    property Model: TCustomNativeDoodadModel read GetModel;
    property Orientation: TDoodadOrientation read GetOrientation write SetOrientation;
    property Value: Single read GetValue write SetValue;
    property OnValueChange: TNotifyEvent read GetOnValueChange write SetOnValueChange;
  end;

  [ComponentPlatformsAttribute(pfidiOS or pidAndroid)]
  TNativeDoodad = class(TCustomNativeDoodad)
  published
    property Align;
    property Anchors;
    property Height;
    property Margins;
    property MaxImage;
    property MinImage;
    property Orientation;
    property Position;
    property Size;
    property Value;
    property Visible default True;
    property Width;
    property OnValueChange;
  end;

SetMaxImage and SetMinImage are not being called when the component is being loaded

Edited by Dave Nottage
Additional info

Share this post


Link to post
2 hours ago, Dave Nottage said:

SetMaxImage and SetMinImage are not being called when the component is being loaded

Which is the whole problem - they're not called when the values are streamed. I needed to override the Loaded method to see that they are.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×