Recent

Author Topic: Normal or Bug?  (Read 2312 times)

jana2000

  • Newbie
  • Posts: 1
Normal or Bug?
« on: December 29, 2024, 01:06:13 pm »
I wanted to create a splash screen for a new project and copied the source code for a splash screen from another project. The code was OK but was apparently ignored by Lazarus.

After some trial and error I found the cause: you have to mark every event in the object inspector. Just declaring it in the unit source code is not enough.

Is this normal or a bug. (Lazarus 3.6)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11999
  • FPC developer.
Re: Normal or Bug?
« Reply #1 on: December 29, 2024, 01:26:16 pm »
Normal.

n7800

  • Full Member
  • ***
  • Posts: 200
Re: Normal or Bug?
« Reply #2 on: December 30, 2024, 11:59:52 pm »
An event is just a class property. If you don't assign it, the class won't call it. And the Object Inspector is, roughly speaking, a simple way to assign a properties to classes (components in form). You can do it yourself in code (in run-time):
Code: Pascal  [Select][+][-]
  1. Button1.OnClick := @Button1Click;

For clarity, the method name doesn't matter. It can be called anything, and it doesn't mention either the component name or the event name - it's just a name created by the IDE by default.

This also means that you can assign the same method to different events (if the number and type of arguments match).

 

TinyPortal © 2005-2018