Recent

Author Topic: Component text property is not working when compiled  (Read 869 times)

Josh

  • Hero Member
  • *****
  • Posts: 1361
Component text property is not working when compiled
« on: January 19, 2025, 11:24:21 am »
Hi
i am getting odd behaviour.

i am creating a component that has a text property, in the object inspector the changes are shown, in designtime the value is correct, but when compiled it gets the wrong value.

ie drop on form, ide shows heading of 'Heading Text' and compiled version matches
Change the Heading text to 'Hello', ide shows heading of 'Hello' and compiled version matches.

Delete/Change the Heading text to '', ide shows heading of '' and compiled version shows heading of 'Heading Text':(.
[added]
The lfm changes accordingly,
Code: [Select]
SP_HeadingText = 'hello' but completely removes the line above when set to nothing in the object Inspector

Code: Pascal  [Select][+][-]
  1. TSuperPanel = class(TCustomPanel)
  2. private
  3.     FHeadingText:String;    
  4.     procedure SetHeadingText(const AValue:String);
  5. ...
  6. published
  7.     property SP_HeadingText:String read FHeadingText write SetHeadingText;
  8. ....
  9. Procedure Register;
  10. implementation
  11. procedure TSuperPanel.SetHeadingText(const AValue: String);
  12. begin
  13.   if FHeadingText <> AValue then FHeadingText := AValue;        
  14. end;
  15.  
  16. constructor TSuperPanel.Create (AOwner: TComponent);
  17. begin
  18.   inherited Create(AOwner);
  19.   FHeadingText:='Heading Text';  
  20. end;  
  21.  
« Last Edit: January 31, 2025, 12:34:42 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

LV

  • Full Member
  • ***
  • Posts: 207
Re: Component text property is not working when compiled
« Reply #1 on: January 19, 2025, 12:43:06 pm »
Maybe (I haven't checked)

Code: Pascal  [Select][+][-]
  1. published
  2.     property SP_HeadingText: String read FHeadingText write SetHeadingText stored True;
  3.  

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: Component text property is not working when compiled
« Reply #2 on: January 19, 2025, 12:54:16 pm »
Use the caption property instead of the text property?
On some components there is a strict distinction.
« Last Edit: January 19, 2025, 01:00:01 pm by Thaddy »
But I am sure they don't want the Trumps back...

Josh

  • Hero Member
  • *****
  • Posts: 1361
Re: Component text property is not working when compiled
« Reply #3 on: January 19, 2025, 01:19:05 pm »
@lv
Thanks for that tried the stored true. unfortunately no effect.
@thaddy
I have tried TCaption, also AnsiString. All the same effect.

I just noticed soething odd.
If i delete the heading text in Object Inspector, then compile project, it displays Heading Text, object inspector still shows Deeted content, if I save/quit/restart lazarus the Object Inspector now shows 'Heading Text' rather than blank.

Lazarus 3.7 (rev lazarus_3_6-48-g38de7307a0) FPC 3.2.3 i386-win32-win32/win64
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1361
Re: Component text property is not working when compiled
« Reply #4 on: January 19, 2025, 01:38:28 pm »
hi
created a workaround not perfect, but seems to work.
when its blank it get sets to NULLNIL, then checks for NULLNIL when displaying
Code: Pascal  [Select][+][-]
  1. const
  2.    NullText='NULLNIL';
  3.  
  4. procedure TSuperPanel.SetHeadingText(const AValue: String);
  5. begin
  6.   if FHeadingText = AValue then Exit;
  7.   If AValue='' then FHeadingText:=NullText
  8.   else FHeadingText := AValue;  
  9.   Paint;
  10. end;
  11.  
  12. Procedure TSuperPanel.Paint;
  13. ....
  14.   if FHeadingText<> NullText then
  15.   begin
  16.      //Display Heading
  17.  
« Last Edit: January 19, 2025, 02:07:05 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1361
Re: Component text property is not working when compiled
« Reply #5 on: January 19, 2025, 02:27:53 pm »
Thought I would upload the package SuperPanel; onlytested on windows.
Its just a concept, but fairly functional.

pic of  test2, multiple panels, if panel has a heading and user moveable is true you can drag it around, if panel has diag lines bottom right then it is resizeable.
it appears in standar palletee red icon.

explore object inspector towards bottom they start SP_ for options/properties


« Last Edit: January 19, 2025, 02:34:14 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1361
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018