55143681 Posted December 3, 2019 Share Posted December 3, 2019 I want to add some spaces among UniLabel's caption, for example, UniLabels's caption="abc 123" but, actually,that can only display one space,"abc 123", why? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 3, 2019 Share Posted December 3, 2019 5 hours ago, 55143681 said: but, actually,that can only display one space,"abc 123", why? This is normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed. There are two exceptions from that: 1. Using <pre> tag: UniLabel1 -> TextConversion = txtHTML UniLabel1 -> <pre>Caption = abc 123</pre> 2. Using CSS: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']); end; UniLabel1 -> TextConversion = txtRegular UniLabel1 -> Caption = abc 123 Quote Link to comment Share on other sites More sharing options...
55143681 Posted December 4, 2019 Author Share Posted December 4, 2019 20 hours ago, Sherzod said: This is normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed. There are two exceptions from that: 1. Using <pre> tag: UniLabel1 -> TextConversion = txtHTML UniLabel1 -> <pre>Caption = abc 123</pre> 2. Using CSS: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']); end; UniLabel1 -> TextConversion = txtRegular UniLabel1 -> Caption = abc 123 1:should be UniLabel1 -> TextConversion = txtHTML; UniLabel1 -> Caption ="<pre> abc 123</pre>"; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 4, 2019 Share Posted December 4, 2019 Just now, 55143681 said: 1:should be UniLabel1 -> TextConversion = txtHTML; UniLabel1 -> Caption ="<pre> abc 123</pre>"; Yes. Quote Link to comment Share on other sites More sharing options...
55143681 Posted December 4, 2019 Author Share Posted December 4, 2019 2 hours ago, Sherzod said: Yes. Can you tell me how to write the sentence with cbuilder? UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']); Quote Link to comment Share on other sites More sharing options...
55143681 Posted December 4, 2019 Author Share Posted December 4, 2019 1 hour ago, 55143681 said: Can you tell me how to write the sentence with cbuilder? UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']); The answer is: void __fastcall TMainForm::UniFormCreate(TObject *Sender) { UniLabel1->JSInterface->JSConfig("style","\"white-space:pre\""); } //--------------------------------------------------------------------------- void __fastcall TMainForm::UniBitBtn1Click(TObject *Sender) { UniLabel1->TextConversion=txtRegular; UniLabel1->Caption="abc 123"; } //--------------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted December 5, 2019 Share Posted December 5, 2019 @55143681 Hello This also works fine : procedure TMainForm.UniButton1Click(Sender: TObject); //===================== const MySpace=' '; //===================== begin UniLabel1.TextConversion:=txtHTML; UniLabel1.Caption:='A' + MySpace +'B'; // for others components (UniMemo1, UniTreeView1, ....) // you don'nt have to specify TextConversion (there are already in txtHTML) end; Cheers. Edit : for many space : UniLabel1.caption := 'A' + MySpace + MySpace + MySpace + MySpace + MySpace + 'B'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.