Recent

Author Topic: event property will not create  (Read 9255 times)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: event property will not create
« Reply #15 on: November 01, 2016, 09:31:53 am »
The problem is not only relayed on the form events, but by all events called by a baseform.
another example:

On my baseform I have created a toolbar with buttons and an actionlist. Lets say two buttons are created: prior and next. These are connected to an action in the actionlist. In the basecode some like this is put:
Code: Pascal  [Select][+][-]
  1. procedure TFrmGUIbasis.acNextExecute(Sender: TObject);
  2. begin
  3.   if datasource1.DataSet <> nil then
  4.     datasource1.DataSet.RecordNext
  5. end;
  6.  
Every new inherited form uses this code if I push the button.
Now I have a new created inherited form with a listbox on it. The next button gets other code to scroll the listbox. So dubbleclick on the event OnExecute of the event should create a new procedure. In the object inspector TFrmGUIbasis.acVerderExecute will changed to acVerderExecute. This should be a local procedure overriden to  TFrmGUIbasis.acNextExecute(Sender: TObject);. Nothing happens. Dubbleclick on the property again comes with this error message:

Quote
Error

Unable to show method. Please fix the error shown in the message window, which is normally below the source editor.

But a new procedure should be created in the editor.

I hopes this is more clearly.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: event property will not create
« Reply #16 on: November 01, 2016, 09:44:06 am »
But your all mistaking about the OnCreate event. I'm not talking about the constructor of the form, but of the property Oncreate of the object inspector. This is creating TForm1.formCreate(Sender : TObject) which will execute after the constructor. Many people thinks you override the constructor, but that's not true.  Constructor TForm1.Create(TheOwner: TComponent); is something different which I don't use (only with livebindings and objects in Delphi :D )
And I'm also not talking about overriding the constructor Create(). I'm talking about overriding DoCreate(). This is a special procedure which is designed to call OnCreate-event. Events are not meant to be implemented in base-forms. Every form-event has a procedure by which it's called. If you want something done in the base-class for that event you should do it in the override of that calling-procedure.

Although I still think events are not meant for base-forms you can do what you want in Delphi. Double-clicking the event in a descendant does create a new FormShow() (although without the inherited). The inherited will never be added (because events are not meant that way) but you can submit a bugfix for the IDE that is doesn't jump to the base-class-event-procedure.

I still feel this is bad design and you need to do the things in DoShow if you want to use them in a FormShow-event in descendants and not use a FormShow-event in the base-class for that (same with the other DoCreate, DoDestroy etc).
« Last Edit: November 01, 2016, 09:45:51 am by rvk »

totya

  • Hero Member
  • *****
  • Posts: 720
Re: event property will not create
« Reply #17 on: November 01, 2016, 09:45:22 am »
My example uploaded just tell my concept. All my forms are inherited from the baseform. Nothing is created dynamically but @designtime.
Frames are nice, but doesn't do inheritence of components.

I give up, I think... :)

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: event property will not create
« Reply #18 on: November 01, 2016, 09:55:54 am »
No. see my first answer. It is not clear.
But we do want to help.... Maybe you just need ctrl-shift-c?
« Last Edit: November 01, 2016, 09:57:36 am by Thaddy »
Specialize a type, not a var.

offline

  • Newbie
  • Posts: 2
Re: event property will not create
« Reply #19 on: November 30, 2016, 08:05:46 pm »
The last few times a procedure will not put in unit when I dubbleclick on a event item in object inspector.

Hello,
few times?
For me dbl click on events does not work at all on inherited forms.

Lazarus 1.6.2
Win10

 

TinyPortal © 2005-2018