[lazarus] Events.
Shane Miller
SMiller1 at stvgb.org
Thu Jul 22 09:00:30 EDT 1999
>>> The Software Company <smartr at mweb.co.za> 07/22 1:45 AM >>>
I am having a few problems with the messages. Could some please explain how they work and if there is any catch that I should be aware of.
I Used the method used in buttons.pp. The difference is that I am applying them to TCombobox. How will this effect the events???
>>>>>>
brent,
The messages are quite simple once you understand how they work.
Each widget has certain messages (signals in GTK) that are sent to it. For example, the BUTTON widget gets a 'clicked' event. Notice, in the difinition for the class, there is a procedure....
Procedure DoClicked(var msg); message LM_CLICKED;
It is connected to that message by the call in TButton.Create SetCallBack(LM_CLICKED);
This is the procedure that receives the "HEY, the button was clicked!" message.
If you go and examine that Procedure, you'll notice that all it does is check to see if the user has assigned a procedure to the FOnCLicked property. The user does this by saying (after they crseate the button)
Button1.OnClicked := @ButtonClicked;
ButtonCLicked is a procedure defined by the user as
PRocedure ButtonClicked(Sender : TObject);
So, when the button is pressed, DoCLicked is called which calls ButtonClicked.
If you need to add a message to a NEW component, see what widget you will be using, go to www.gtk.org and look at the gtk reference material and determine what signals it can handle.
Hope this helps....
Shane
More information about the Lazarus
mailing list