Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A small bug in 15.2.56
#1
I have a TIWText component called MyText.

I do

-- Any ASYNC event (for example OnAsyncClick of a TIWButton)
MyText.Text := 'My awesome text';
-- End of Any ASYNC event

The first time I see rendered the text 'My awesome text'.

If I run again the ASYNC event (I click again on the button),  the TIWText does render nothing. Empty HTML.

If I use this workaround

-- Any ASYNC event (for example OnAsyncClick of a TIWButton)
MyText.Lines.Clear;
MyText.Lines.Add('My very beautiful text');
-- End of Any ASYNC event

Then everything work great.


Tried in 15.2.56 (D11.2), no other versions.

Thanks,
Eddy
Reply
#2
Hi Eddy,

I assume you use IW15.2.65, the current latest version?

I tested this with IW15.2.65 and it works as expected. The second time you press the button nothing changes to the text property. The text stays the same. That's why no rendering event for the browser is needed. If you need it to render even if the text stays the same, you can also use MyText.Invalidate. In the end the effect is the same.
Reply
#3
(09-30-2022, 12:34 PM)jeroen.rottink Wrote: Hi Eddy,

I assume you use IW15.2.65, the current latest version?

I tested this with IW15.2.65 and it works as expected. The second time you press the button nothing changes to the text property. The text stays the same. That's why no rendering event for the browser is needed. If you need it to render even if the text stays the same, you can also use MyText.Invalidate. In the end the effect is the same.

Sorry I wrote two times the wrong version Tongue . Yes it is the last version (15.2.65).
Yes the problem is the one you write, but I don't think it is the right behaviour, do you?
And why with the TStrings property "Lines" it is fine?

Thanks,
Eddy
Reply
#4
Hi Eddy,

That is because first you clear the lines resulting in Text = ''. After that you assign it the new text.

The same would be

begin
  MyText.Text := '';
  MyText.Text := 'My awesome text';
end;

When you write a 'Setter' for a property it is good practice to do:

procedure TMyClass.SetText(const AValue: string);
begin
  if (FText <> AValue)
  then begin
    FText := AValue;
    DoSomeChangeAction;
  end;
end;

Hope this makes sense.
Reply
#5
If you need it to force refresh, call Invalidate method after changing the text.

Anyway... I believe the correct behavior should be: render whenever text changes, and don't render otherwise.
Reply
#6
Sorry for the late.
Maybe I didn't explain well the issue.

If I set for the second time the "Text" property of MyText with same text, in an async mode, on the HTML I see the text that disappear.
If I do the same with "Lines" (even without "clear") the behaviour is correct.

I think that even if I set again the same text in a TIWText, then it must not be "cleaned" in HTML.

That's it.

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)