[lazarus] GTK message handlers.
Cliff Baeseman
vbman at pcpros.net
Sun Apr 25 23:38:44 EDT 1999
Shane what do you think about this? I think we should leave our current form of events in place
for now since it seems to work very well.
What are yur thoughts on this.
Cliff
michael at tfdec1.fys.kuleuven.ac.be wrote:
> Hello,
>
> As requested by Michael Zayats, we've implemented some changes to support
> messages from GTK more directly.
>
> The implementation of it is as follows:
>
> Declare a message handler with SELF as one of the paameters.
>
> Procedure TMyClass.MyMessageHandler (Arg1 : Type1; Arg2 : Type2;
> ...
> Self : TMyClass;
> Argn : Typen); message 'themessage';cdecl;
>
> What happens is the following: For string message handlers, you can specify
> SELF as one of the parameters. The compiler will then load this parameter in
> the SELF register of the class.
> The type of SELF must be the same as the type of the class, or an error
> will occur. It is also only possible for 'string' message handlers.
>
> This means that you can do for instance:
>
> Procedure TMyDangerButton.FormatHarddrive (Widget : PGtkWidget;
> Self : TMyDangerButton);message 'clicked'; cdecl;
>
> begin
> FormatDisk('C:');
> end;
>
> Procedure TMyDangerButton.Create()
>
> begin
> // Create the GTK button widget
> // Connect to onclick handler, pass self as data.
> gtk_signal_connect(gtk_Object(fcomponent),
> 'clicked',
> gtk_Signal_Func(@FormatHardDrive),
> Self);
> // No way to avoid the ugly typecast... This is Pascal, after all..
> end;
>
> So no global dispatching functions or whatever are needed.
>
> This has been put in the compiler, but not yet tested or committed to CVS,
> although the generated code looks OK.
>
> I will notify when it has been committed and tested.
>
> Michael.
>
> _________________________________________________________________
> To unsubscribe: mail lazarus-request at miraclec.com with
> "unsubscribe" as the Subject
More information about the Lazarus
mailing list