Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

GTK and Object Pascal

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fernando Lozano

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

Reply by email