On Fri, 8 Apr 2022, Mattias Gaertner via lazarus wrote:

On Fri, 8 Apr 2022 14:21:23 +0200
Sven Barth via lazarus <lazarus@lists.lazarus-ide.org> wrote:

[...]
Solving this would at the same time allow the IDE to have a TButton
for both the LCL and e.g. Web Components Library. Right now they need
to be named differently like WebCtrls.TWButton.

Note that if you just want to support two TButton, then you don't need
to extend Classes. You can use TReader.OnFindComponentClass.
Only if you want two different TButton on the same form you need the
unitname.tbutton.

To support 2 different TButtons at runtime, no hook is needed if you don't drop 
them
on the same form. The entry in field classtable will automatically point to
the correct one.

It's only needed if there is no field, then you will need a hook (as in the IDE which - if I am correctly informed - uses a JIT form).


I will try to summarize:

a) Extend lfm to support unitname.classname and extend IDE to allow
registering classnames twice.

Pro: Allows two TButton in the same app, even on the same form.

Con: Require changes in Classes (FPC release)

Con: old and new lfm file troubles (old/new FPC, old/new IDE)


b) Extend IDE with environment tags for pages and allow registering
classnames twice for different environments.

Pro: IDE could show context sensitive component palette

Pro: allows two TButton in IDE

Con: does not support two TButton in one app, unless app sets
TReader.OnFindComponentClass

Con: troubles with old IDE


Note that a) and b) are not xor - both can be implemented.

Exactly.

a/ I don't think that requiring a special hook to accomodate something
   that is baked into the language is a correct approach.
   The language provides scoped names, so the streaming should support this 
correctly
   without resorting to "hacks". It should have been so since day 1.


b/ This can be done today already without waiting for a/ and thereby make
   using similarly named components possible for pas2js and native apps.

   You may want to enable setting multiple environments for a page:
   e.g. TTimer is usable in a service and in GUI app. Same for data access.
   (but it should not be available for pas2js) While I am not against doing
   it for a page, I think doing it at the component level is in the end the
   more powerful choice. (Delphi does it that way)

Michael.


--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to