[Lazarus] Change default component name

Michalis Kamburelis michalis.kambi at gmail.com
Wed Oct 12 06:46:01 CEST 2011


Hi,

When you drop a component on a form, by default the name of the
component is derived from the ClassName with leading 'T' removed (and
number suffix added). Now, I'm wondering about registering a class named
T3DScene as a component, and this causes problems: when you drop this
component on a Lazarus form, the default name is "3DScene1", which
obviously isn't a valid Pascal identifier. Lazarus shows an error
message "Error setting the name of a component :T3DScene to 3DScene1"
and refuses to add the component to the form.

1. Is there a solution for this? Is there maybe a virtual method like
TComponent.GetDefaultName that I can override, or some other way to tell
Lazarus that the default name for T3DScene class should be like
"Scene1", "Scene2" etc.?

2. Or do I just have to rename the class (to e.g. "TScene" or
"TScene3D") to make it work without problems with form designer?

Browsing the Lazarus sources, I didn't see any such way (it seems that
the logic to remove 'T' from ClassName is just hardcoded in some
places), so I'm guessing it's 2., but wanted to make sure :)

Thanks,
Michalis




More information about the Lazarus mailing list