[gtkada] Callback to filter keys.

Martin Klaiber martinkl at zedat.fu-berlin.de
Sun Feb 23 19:12:06 CET 2003


Hi,

I have a problem with callbacks again. In an application I need a
large number of entries who take only numbers, so I want to use an
inheritance with this capability. But I can't find the right callback.


In the specification I defined:
  
  type Num_Entry_Record is new Gtk_Entry_Record with null record;
  ...
  procedure Initialize (Num_Entry : Num_Entry_Access);
  function Check_Keys (Num_Entry : Num_Entry_Access; 
                       Event : Gdk_Event_Key) return boolean;


In the body I have:
  
  package Check_Keys_Callback is
    new Gtk.Handlers.Return_Callback (Num_Entry_Record, Boolean);

  procedure Initialize (Num_Entry : Num_Entry_Access) is
  begin
    ...
    Check_Keys_Callback.Connect (Num_Entry, "key_press_event",
      Check_Keys_Callback.To_Marshaller (Check_Keys'Access));
    ...                                            ^
  end Initialize;                                  |
                                                   |
                                                   |
The error-message: (it appears here ---------------')

  numerical_entry.adb:25:26: no candidate interpretations match the actuals:
  numerical_entry.adb:25:52: expected type "Handler" 
    defined at gtk-marshallers.ads:149, 
    instance at gtk-handlers.ads:263, 
    instance at line 12
  numerical_entry.adb:25:52: found type access to "Check_Keys" 
    defined at line 25

Does someone know what's wrong here? To my opinion the types should be
right.

Thanks, Martin



More information about the gtkada mailing list