[fpc-pascal]GTK and Object Pascal
Fernando Lozano
fsl at centroin.com.br
Thu Jul 25 07:31:34 CEST 2002
Hi there,
I am building a small GTK app on Free Pascal, using the provided Gtk+ unit. As each window has a lot of code to build the UI, I decided each Window will be one class.
I found I can use any method without arguments as an argument to signal_conect. For example, if my class TForm has a method named Edit I can do something like:
constructor TForm.Create;
begin
...
gtk_signal_connect (button, 'click', GTK_SIGNAL_FUNC (@TWin.Edit), nil)
...
end;
But if I try to declare any kind of argument to TWin.Edit I get an "Illegal type conversion" error.
I want to use a class method as the event handler for buttons inside my windows. But I need to pass this method some data. I assume I cannot use the self variable (does OO has static methods like C++ and Java?), or am I wrong? So how I do pass data to the event handler? Will I have to use standard procedures instead of methods? Is there a way to pass a pointer to the instance so I can call its methdos from the event handler? Any hint will be welcome.
[]s, Fernando Lozano
More information about the fpc-pascal
mailing list