Recent

Author Topic: Missing Object Inspector Property Editor Option  (Read 1341 times)

SandyG

  • Jr. Member
  • **
  • Posts: 91
Missing Object Inspector Property Editor Option
« on: June 26, 2024, 05:11:01 am »
Not sure what to do here, I have a class that inherits the 'Caption' property ultimately from a TControl.  Some of the common properties in the Object inspector show up with the '...' Ellipsis, like a TFont, seems OK, but a TCaption does not show the Ellipsis, so no way to bring up that default property editor for a TCaption (really resolves to a TString from what I see). Looks at the docs for custom property editors but seems like way overkill for default one that are sorta' working in the Object Inspector.

What's odd is the TControl class defines both the Font and the Caption, and that is just inherited by my classes. Might have missed something in looking at other classes that subclass from the TControl like a TLabel both of which show up in the Property Editor with the '...' when inspecting.

Seems like an easy one, but can't find much here on the forum or it's lost in the search, as I didn't find much except on custom editors.

How can I make props like these have the default property editor option show up in the object inspector??

Lazarus version info in the image

Sandy

Class defs below (trimmed a lot)...


Code: Pascal  [Select][+][-]
  1. // the chain of subclassing
  2.  
  3. TGraphicControl = class(TControl)
  4. ...
  5.  
  6. TDTCustomThemedGauge = class(TGraphicControl)
  7. ...
  8.  
  9. TDTThemedGauge = class(TDTCustomThemedGauge)
  10.   private
  11.     { Private declarations }
  12.   protected
  13.     { Protected declarations }
  14.   public
  15.     { Public declarations }
  16.   published
  17.     { Published declarations }
  18.     property Caption;  // No '...', no way to use the caption/string property editor
  19.     property Font;  // this will show the '...' and pop the property editor when clicked
  20. ...
  21.  
« Last Edit: June 26, 2024, 05:13:04 am by SandyG »

Ten_Mile_Hike

  • Jr. Member
  • **
  • Posts: 69
Re: Missing Object Inspector Property Editor Option
« Reply #1 on: June 27, 2024, 08:02:56 am »
Maybe I'm being stupid, but have you tried "Text" instead of "Caption"?

dsiders

  • Hero Member
  • *****
  • Posts: 1208
Re: Missing Object Inspector Property Editor Option
« Reply #2 on: June 27, 2024, 09:12:17 am »
The Ellipsis just indicates that a multi-line property editor has been registered for the class member. Without it, TCaption is a single line of text. In LCL, not every TCaption instance uses a multi-line property editor.

If that's what you *really* want then call RegisterPropertyEditor() in your Register() routine for the unit or package.Plenty of examples of this in the LCL IDE interface. (components/ideintf).
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4515
  • I like bugs.
Re: Missing Object Inspector Property Editor Option
« Reply #3 on: June 27, 2024, 03:49:27 pm »
Checking the code.
Code: Pascal  [Select][+][-]
  1. type
  2.   TCaption = TTranslateString;
and
Code: Pascal  [Select][+][-]
  1. TTranslateString = type String;
There is no property editor defined for TCaption or TTranslateString.
TStrings has a property editor.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

SandyG

  • Jr. Member
  • **
  • Posts: 91
Re: Missing Object Inspector Property Editor Option
« Reply #4 on: June 27, 2024, 05:18:22 pm »
Great info.

I will poke around in the code, I looked at registering property editors but couldn't find an example but I will look again. What's odd is that I was sure that TCaption in another component was working with the TString like property editor.

Learning more each day, hopefully I'll remember it.

I like the idea of trying to use the RegisterPropertyEditor(),  that is a better solution I think in messing with a bunch of the simple properties that I'm adding to the AnalogGauge, and would be nice to be able to add them when appropriate. I think the problem I had was that the main component was using another class that had the TCaption, and that class was not being registered as a component but being used by the one that was being registered so was not sure how to make it work.

Lots to keep learning!

Thanks for the explanations on why it didn't work, now at least I know how it works.

Sandy





JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4515
  • I like bugs.
Re: Missing Object Inspector Property Editor Option
« Reply #5 on: June 27, 2024, 10:05:28 pm »
Oops, I gave wrong information earlier. Please see this in unit PropEdits, package IdeIntf :
Code: Pascal  [Select][+][-]
  1. procedure InitPropEdits;
  2. begin
  3.   // Don't create PropertyClassList and PropertyEditorMapperList lists here.
  4.   // RegisterPropertyEditor and RegisterPropertyEditorMapper create them,
  5.   //  and they are called from many initialization sections in unpredictable order.
  6.  
  7.   // register the standard property editors
  8.   RegisterPropertyEditor(TypeInfo(AnsiString), TComponent, 'Name', TComponentNamePropertyEditor);
  9.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomLabel, 'Caption', TStringMultilinePropertyEditor);
  10.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomStaticText, 'Caption', TStringMultilinePropertyEditor);
  11.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomCheckBox, 'Caption', TStringMultilinePropertyEditor);
  12.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomSpeedButton, 'Caption', TStringMultilinePropertyEditor);
  13.   RegisterPropertyEditor(TypeInfo(TTranslateString), TMenuItem, 'Caption', TMenuItemCaptionEditor);
  14.   RegisterPropertyEditor(TypeInfo(TTranslateString), TComponent, 'Hint', TStringMultilinePropertyEditor);
  15.   RegisterPropertyEditor(TypeInfo(TCaption), TGridColumnTitle, 'Caption', TStringMultilinePropertyEditor);
  16.   RegisterPropertyEditor(TypeInfo(TTabOrder), TControl, 'TabOrder', TTabOrderPropertyEditor);
  17.   RegisterPropertyEditor(TypeInfo(ShortString), nil, '', TCaptionPropertyEditor);
  18.   RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TStringsPropertyEditor);
  19.   RegisterPropertyEditor(TypeInfo(TFileName), nil, '', TFileNamePropertyEditor);
  20.   RegisterPropertyEditor(TypeInfo(AnsiString), nil, 'SessionProperties', TSessionPropertiesPropertyEditor);
  21.   RegisterPropertyEditor(TypeInfo(TModalResult), nil, 'ModalResult', TModalResultPropertyEditor);
  22.   RegisterPropertyEditor(TypeInfo(TShortCut), nil, '', TShortCutPropertyEditor);
  23.   //RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TDate'), nil,'',TDatePropertyEditor);
  24.   //RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TTime'), nil,'',TTimePropertyEditor);
  25.   RegisterPropertyEditor(TypeInfo(TDateTime), nil, '', TDateTimePropertyEditor);
  26.   RegisterPropertyEditor(TypeInfo(TCursor), nil, '', TCursorPropertyEditor);
  27.   RegisterPropertyEditor(TypeInfo(TComponent), nil, '', TComponentPropertyEditor);
  28.   RegisterPropertyEditor(TypeInfo(TComponent), nil, 'ActiveControl', TComponentOneFormPropertyEditor);
  29.   RegisterPropertyEditor(TypeInfo(TControl), TCoolBand, 'Control', TCoolBarControlPropertyEditor);
  30.   RegisterPropertyEditor(TypeInfo(TCollection), nil, '', TCollectionPropertyEditor);
  31.   RegisterPropertyEditor(TypeInfo(TFlowPanelControlList), TFlowPanel, 'ControlList', TNoAddDeleteCollectionPropertyEditor);
  32.   RegisterPropertyEditor(TypeInfo(TControl), TFlowPanelControl, 'Control', THiddenPropertyEditor);
  33.   RegisterPropertyEditor(TypeInfo(AnsiString), TFileDialog, 'Filter', TFileDlgFilterProperty);
  34.   RegisterPropertyEditor(TypeInfo(AnsiString), TFilterComboBox, 'Filter', TFileDlgFilterProperty);
  35.   RegisterPropertyEditor(TypeInfo(AnsiString), TFileNameEdit, 'Filter', TFileDlgFilterProperty);
  36.   RegisterPropertyEditor(TypeInfo(AnsiString), TCustomPropertyStorage, 'Filename', TFileNamePropertyEditor);
  37.   RegisterPropertyEditor(TypeInfo(TStrings), TValueListEditor, 'Strings', TValueListPropertyEditor);
  38.   RegisterPropertyEditor(TypeInfo(TCustomPage), TCustomTabControl, 'ActivePage', TNoteBookActiveControlPropertyEditor);
  39.   RegisterPropertyEditor(TypeInfo(TSizeConstraints), TControl, 'Constraints', TConstraintsPropertyEditor);
  40.   RegisterPropertyEditor(TypeInfo(TStrings), TNoteBook, 'Pages', TPagesPropertyEditor);
  41.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomTaskDialog, 'Text', TStringMultilinePropertyEditor);
  42.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomTaskDialog, 'ExpandedText', TStringMultilinePropertyEditor);
  43.   RegisterPropertyEditor(TypeInfo(TTranslateString), TCustomTaskDialog, 'FooterText', TStringMultilinePropertyEditor);
  44.  
  45.   // Property is hidden and editing disabled by HiddenPropertyEditor :
  46.   RegisterPropertyEditor(TypeInfo(TAnchorSide), TControl, 'AnchorSideLeft', THiddenPropertyEditor);
  47.   RegisterPropertyEditor(TypeInfo(TAnchorSide), TControl, 'AnchorSideTop', THiddenPropertyEditor);
  48.   RegisterPropertyEditor(TypeInfo(TAnchorSide), TControl, 'AnchorSideRight', THiddenPropertyEditor);
  49.   RegisterPropertyEditor(TypeInfo(TAnchorSide), TControl, 'AnchorSideBottom', THiddenPropertyEditor);
  50.   RegisterPropertyEditor(TypeInfo(LongInt), TControl, 'ClientWidth', THiddenPropertyEditor);
  51.   RegisterPropertyEditor(TypeInfo(LongInt), TControl, 'ClientHeight', THiddenPropertyEditor);
  52.   RegisterPropertyEditor(TypeInfo(AnsiString), TCustomForm, 'LCLVersion', THiddenPropertyEditor);
  53.   RegisterPropertyEditor(TypeInfo(AnsiString), TCustomFrame, 'LCLVersion', THiddenPropertyEditor);
  54.  
  55.   // since fpc 2.6.0 WordBool, LongBool and QWordBool only allow 0 and 1
  56.   RegisterPropertyEditor(TypeInfo(WordBool), nil, '', TBoolPropertyEditor);
  57.   RegisterPropertyEditor(TypeInfo(LongBool), nil, '', TBoolPropertyEditor);
  58.   RegisterPropertyEditor(TypeInfo(QWordBool), nil, '', TBoolPropertyEditor);
  59.  
  60.   RegisterPropertyEditor(TypeInfo(IInterface), nil, '', TInterfacePropertyEditor);
  61.   RegisterPropertyEditor(TypeInfo(Variant), nil, '', TVariantPropertyEditor);
  62. end;
It registers property editors for LCL components and types.
Other packages register more editors.
For example a multiline editor for TTranslateString Caption is registered for certain components like TCustomLabel. Indeed a Label Caption has ellipsis and an editor.

The TStrings editor is registered for all properties of type TStrings in all components.
Code: Pascal  [Select][+][-]
  1. RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TStringsPropertyEditor);

I should always double check before writing.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

SandyG

  • Jr. Member
  • **
  • Posts: 91
Re: Missing Object Inspector Property Editor Option
« Reply #6 on: June 28, 2024, 05:53:57 am »
No worries, and THANK YOU for the hints where to find the examples. Will help.

Let's see how far I can get ;)

Sandy

 

TinyPortal © 2005-2018