Handler needs to be in a package you with.
begin -- Gtk.Init;
Gtk.Main.Init;
Gtk.Window.Gtk_New (Window => Win, The_Type =>
Gtk.Enums.Window_Toplevel);
Win.Set_Position (Win_Pos_Center);
Gtk.Window.Set_Title (Window => Win, Title => "Editor");
Gtk.Window.Show_All (Win);
Win.On_Button_Press_Event <------------ line that gets the error
(Call => Handler'Access,
After => False,
Slot => Win);
Gtk.Main.Main;
end test1;
I get the compiler error message:
test1.adb:32:17: subprogram must not be deeper than access type
in the following program:
with Gtk.Enums; use Gtk.Enums;
with Gtk.Main;
with Gtk.Window;
with Gdk;
with Gdk.Event;
with Glib;
with Glib.Object;
procedure test1 is
Win : Gtk.Window.Gtk_Window;
function Handler
(Self : access Glib.Object.GObject_Record'Class;
Event : Gdk.Event.Gdk_Event_Button) return Boolean is
begin
Gtk.Main.Main_Quit;
return True;
end Handler;
--
-- defined in gtk-widget.ads
--
-- type Cb_GObject_Gdk_Event_Button_Boolean is not null access function
-- (Self : access Glib.Object.GObject_Record'Class;
-- Event : Gdk.Event.Gdk_Event_Button) return Boolean;
begin -- Gtk.Init;
Gtk.Main.Init;
Gtk.Window.Gtk_New (Window => Win, The_Type => Gtk.Enums.Window_Toplevel);
Win.Set_Position (Win_Pos_Center);
Gtk.Window.Set_Title (Window => Win, Title => "Editor");
Gtk.Window.Show_All (Win);
Win.On_Button_Press_Event <------------ line that gets the error
(Call => Handler'Access,
After => False,
Slot => Win);
Gtk.Main.Main;
end test1;
I get the compiler error message:
test1.adb:32:17: subprogram must not be deeper than access type
What does this mean and how can I correct it?
On 01/09/2023 22:41, Luke A. Guest wrote:....;
Handler needs to be in a package you with.
begin -- Gtk.Init;
test1.adb:32:17: subprogram must not be deeper than access type
Ada doesn't like 'access types to be in an area that can go out of scope iirc. You can get around it with unchecked_access, but if you put
handler into a package of it's own, it's at library level and is
available to grab the access of.
Under gtkada, must procedures that handle events always be in their
own package?
richardthiebaud <thiebauddick2@aol.com> writes:
Under gtkada, must procedures that handle events always be in their
own package?
In general, they'd need to be in _a_ package. You could group related
event handlers in a package.
richardthiebaud <thiebauddick2@aol.com> writes:
Under gtkada, must procedures that handle events always be in their
own package?
In general, they'd need to be in _a_ package. You could group related
event handlers in a package.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 44:22:06 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,953 |