How to assign button event

in documentation nothing is said about the buttons and how to assign the button1 events without the CGE editor
There is something written on this site about buttons, but nothing is clear:
How to add this to TCastleWindow.The controls?
Where is TCastleWindow located.The controls?
Why does the debugger indicate that button1 is not a function?

  1. define the button in the “published” part (you need the unit CastleControls in the uses section)
  2. define the click procedure in the “private” part

  1. in the procedure start you have to define the click event

  1. write the click procedure (what should happen when you click the button)

grafik

2 Likes

Hi, Didi gives you a good answer , but let me give you a trick if you use Lazarus as editor

After define the button in published section, you can go direct to procedure Start.

Write the assignation

buttonCarSelect.onclick :=@ClickSelect;

As you finish, don’t press enter, and press ctrl+shift+c, then Lazarus will create the definition of procedure in private section, and move the cursor to the new procedure.

/BlueIcaro

1 Like