A small bug in 15.2.56

<< Click to Display Table of Contents >>

Navigation:  Forum >

A small bug in 15.2.56

Forum link

 


 

09-30-2022, 10:21 AM:

 

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

 


 

09-30-2022, 12:34 PM:

 

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.

 


 

09-30-2022, 12:49 PM:

 

(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  . 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

 


 

09-30-2022, 04:00 PM:

 

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.

 


 

10-06-2022, 06:27 AM:

 

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.

 


 

10-18-2022, 06:38 AM:

 

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