Jump to content

SetText is not a function ?


Abaksoft

Recommended Posts

Hello Sherzod,

1. In Desktop mode this works fine :

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniLabel1.JSInterface.JSCall('setText', ['Hello']);
end;

 

2. In Mobile Form :

procedure TMainmForm.UnimButton1Click(Sender: TObject);
begin
  UnimLabel1.JSInterface.JSCall('setText', ['Hello']);
end;

raise error :  "...setText is not a function"

How can i solve this ?

Thx

Link to comment
Share on other sites

13 minutes ago, Sherzod said:

UnimLabel1.JSInterface.JSCall('element.setText', ['Hello']);

 

Mmm...Thank you Sherzod, this JS works fine but not solve my problem.

Infact, it's related to centring text on a moble Form. I can't get a good center after changing unimLabel1.Caption.

I was thinking wrongly, to change it via JS but nothnig ?!

Here is a testCase. Can you please kindly have look ?

The pupose is to maintain centering even with changing caption.

Thx.

1.Center_Center.7z

1.png

2.png

Link to comment
Share on other sites

36 minutes ago, Abaksoft said:

Infact, it's related to centring text on a moble Form. I can't get a good center after changing unimLabel1.Caption.

    UnimLabel1.JSInterface.JSCall('element.setText', ['111111 2222222222222  3333333333333333']);
    UnimLabel1.JSInterface.JSCall('element.setStyle', ['text-align', 'center']);

 

Link to comment
Share on other sites

12 minutes ago, Sherzod said:

    UnimLabel1.JSInterface.JSCall('element.setText', ['111111 2222222222222  3333333333333333']);
    UnimLabel1.JSInterface.JSCall('setWidth', ['auto']);

 

Many Thanks Maestro,

I am taking a big cofee with delicious cakes with family. i will check it tomorrow ان شاء الله

Cheers.

  • Like 1
Link to comment
Share on other sites

18 hours ago, Sherzod said:

    UnimLabel1.JSInterface.JSCall('setWidth', ['auto']);

 

Perfect Maestro,

Finally your JSCall is a good replacement of autosize methode, wich should be improved.

I Opened a Ticket FSD-2381

 

Resume :

A.  Problem :
  UnimLabel.Autosize := True   not works, if caption change at Runtime.

 

B.  Solution :

   UnimLabel1.JSInterface.JSCall('setWidth', ['auto']);
   UnimLabel1.Caption:='111111 2222222222222  3333333333333333';

  • Upvote 1
Link to comment
Share on other sites

×
×
  • Create New...