Recent

Author Topic: Suggestion: Show public methods of components in the Object Inspector?  (Read 5616 times)

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
When you drop a component onto a form, the Object Inspector shows you all the published properties - which is very useful

Many components have methods which you need to know - even if it's something simple like 'Execute' (dialog components for example)

Wouldn't it be nice if the Object Inspector had an extra tab to display all the component's useful public methods?

The component code could maybe have a new directive to add to a public method to indicate it should be shown in the Object Inspector.  Something like:

Type
MyComponent = Class(TComponent)
private
 fprivatevar:string;
 procedure Dosomething;
public
  Constructor Create(AOwner); override;
  Destructor Destroy; override;
  procedure Execute; publish;
  procedure HiddenProc;
published
 property etc.

Presumably a new directive like this wouldn't break existing code or compatibility.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Published properties in OI are shown because they are part of RTTI.

If you need to know methods of some object, write NameOfObject.<press Ctrl+Space> and Lazarus will show them all.
Or simply hit F1 and - if everything is configured well - Laz. will open browser with documentation.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Published properties in OI are shown because they are part of RTTI.

If you need to know methods of some object, write NameOfObject.<press Ctrl+Space> and Lazarus will show them all.
Or simply hit F1 and - if everything is configured well - Laz. will open browser with documentation.

That's very true, and I use it to find public methods. But...
The completion list has ALL the methods and properties of the family tree right back to TObject.  That is useful in many contexts, but downright frustrating in others.

My suggestion is more subtle, and would only apply to components in the IDE palette.  The Object Inspector/'publish' directive would act in concert to display only the public methods the component writer tagged. (and ancestor tagged methods of course)

I think it would be genuinely useful when a developer first uses an unfamiliar component; kind-of in the spirit of RAD, and it involves very little extra effort for the component writer (just add the 'publish' directive to selected public methods)

I agree it's not a need, but a wish. (and would be another enhancement of Lazarus over Delphi)
« Last Edit: June 10, 2014, 12:17:42 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
If you want properties in OI: publish them.
And there certainly is no place for methods in OI.

So what you want is never going to happen, but feel free to discuss it here.

Bart

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Quote
The completion list has ALL the methods and properties of the family tree right back to TObject.

Maybe some advanced (configurable) sorting/filtering in code completion should be enough? I also think that OI is not the right place for list of available methods.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

howardpc

  • Hero Member
  • *****
  • Posts: 4144
The Code Explorer window allows you to browse all properties, methods and fields of a class whatever their visibility, and jump to ancestor classes to inspect them too.
Why duplicate this in the OI and clutter it up even more (I think I'm not the only one who doesn't use the Favorites page at all, and the Restricted page only rarely, because I find it difficult to interpret the information there)? For complex classes - and component palette controls are usually quite complex - the amount of information can be overwhelming. On the whole I prefer to have the OI display the minimum information needed, and resort to the Code Explorer (or browsing the source) only if needed.
Obviously people's preferences vary ... but I can't see any compelling reason to implement your suggestion.

 

TinyPortal © 2005-2018