Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-01

Declaration of an event type inside a class

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Werner Pamler

The TAChart code contains a strange declaration:

   TChart = class(TCustomChart, ICoordTransformer)
   public
   type
     TDrawEvent = procedure (ASender: TChart; ADrawer: IChartDrawer) of
object;
   strict private // Property fields
     FOnAfterDraw: TDrawEvent;
     ....
   published
     property OnAfterDraw: TDrawEvent read FOnAfterDraw write
SetOnAfterDraw;

The declaration of TDrawEvent is part of the TChart declaration! As reported in the German Lazarus forum
(http://www.lazarusforum.de/viewtopic.php?f=18&t=8474), an error "Unable to show method..." is generated because of this construction: If I move the TDrawEvent out of the TChart context everything works fine.

I cannot reach Alexander S Klenin for clarification. But what could have been his intention of doing it this way? (Or maybe it is just a typo?)

Reply by email

Alexander Klenin
to Werner Pamler
Werner Pamler wrote 8 lines
The declaration of TDrawEvent is part of the TChart declaration! As reported in the German Lazarus forum (http://www.lazarusforum.de/viewtopic.php?f=18&t=8474), an error "Unable to show method..." is generated because of this construction: If I move the TDrawEvent out of the TChart context everything works fine. I cannot reach Alexander S Klenin for clarification. But what could have been his intention of doing it this way? (Or maybe it is just a typo?)

Yes, it was, to lower the namespace pollution (and to play with a modern FPC feature along the way :-) ).
If this event is moved out of TChart, it should probably be called "TChartDrawEvent" or similar.

Alexander S. Klenin

Reply by email

Alexander Klenin
to Werner Pamler
Werner Pamler wrote
Fine, I'll do it like that.

FWIW, in my my opinion it is preferable to fix CodeTools, since it feels awkward to avoid legitimate language
feature just because IDE does not like it.

BTW: Nice to hear from you again, Alexander, you seem to have been extremely busy.

There were a several unexpected health and job issues that prevented me from doing open-source work, sorry.
Now that they are mostly resolved, maybe I will return to Lazarus project.

Alexander S. Klenin

Reply by email