1

I was playing arround with LiveBindings but I cant make TObjectBindSourceAdapter to work. I doesn't change the properties on my object. I've also tried this example. Same problem.

I have a FMX application, with only a checkbox on the form

Then I've made a simple class:

  TSettings = class
  private
    FTest: Boolean;
    procedure SetTest(const Value: Boolean);
  public
    property Test: Boolean read FTest write SetTest;
  end;

{ TSettings }

procedure TSettings.SetTest(const Value: Boolean);
begin
  FTest := Value;
end;

Then I've made the binding using the designer:

enter image description here

I've created the adapter:

procedure TFormMain.PrototypeBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
begin
  ABindSourceAdapter := TObjectBindSourceAdapter<TSettings>.Create(Self, TSettings.Create, True);
end;

And added an OnChangeEvent to the CheckBox:

procedure TFormMain.CheckBox1Change(Sender: TObject);
begin
  TLinkObservers.ControlChanged(Sender as TComponent);
end;

But if I set a breakpoint in SetTest it never gets there.

What am I missing?

The project can be downloaded here

Jens Borrisholt
  • 6,174
  • 1
  • 33
  • 67

1 Answers1

2

I know this is quite weird if you have already your PrototypeBindSource AutoPost property set to True, but you have to explicitly set (start edit) the related TBindSourceAdapter (end edit) by code in your procedure TFormMain.PrototypeBindSource1CreateAdapter, with

ABindSourceAdapter.AutoPost := true;

Besides, what is your Link component class?

Didier Cabalé
  • 385
  • 3
  • 10
  • AutoPost is true, and PrototypeBindSource is active. I've updateted the question with a lint where to download my demo project – Jens Borrisholt Nov 16 '20 at 14:11
  • 1
    @Jens, but it works! -> please read carefully my solution: "..but you have to explicitly set it by code in your procedure TFormMain.PrototypeBindSource1CreateAdapter, with *ABindSourceAdapter.AutoPost := true;*" Actually, this is the TObjectBindSourceAdapter that you need to set to AutoPost to true, although the related TPrototypeBindSource is already AutoPost true – Didier Cabalé Nov 16 '20 at 14:41
  • Tes. Thank you. I've missed that – Jens Borrisholt Nov 16 '20 at 14:53
  • 2
    Relatively to this, I posted an issue in Embarcadero Quality that points this possible confusion: https://quality.embarcadero.com/browse/RSP-31642 – Didier Cabalé Nov 16 '20 at 15:23