Deutsch   English   Français   Italiano  
<e0c35ed1-c15f-419f-a724-07a3c3bf5d2an@googlegroups.com>

View for Bookmarking (what is this?)
Look up another Usenet article

X-Received: by 2002:ac8:7ef6:: with SMTP id r22mr2978685qtc.158.1631759397855;
        Wed, 15 Sep 2021 19:29:57 -0700 (PDT)
X-Received: by 2002:a05:6808:604:: with SMTP id y4mr7706751oih.86.1631759397594;
 Wed, 15 Sep 2021 19:29:57 -0700 (PDT)
Path: ...!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: fr.comp.lang.ada
Date: Wed, 15 Sep 2021 19:29:57 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=102.142.60.58; posting-account=rdYO6wkAAAAd45iu4u7Y67MQUwG0Eumn
NNTP-Posting-Host: 102.142.60.58
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e0c35ed1-c15f-419f-a724-07a3c3bf5d2an@googlegroups.com>
Subject: Les Callback en Ada
From: Danielle Mandi Mayagha <dmandimayagha@gmail.com>
Injection-Date: Thu, 16 Sep 2021 02:29:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 75
Bytes: 3579

Salut Salut Je viens avec un tout petit (un gros enfaite) probl=C3=A8me  qu=
i me sauf un peu le cerveau. bon voila! j'essaie de faire un Callback avec =
un Bouton mais le souci c'est que ce bon vieux Gnat me dit ceci ( pour info=
 je suis carr=C3=A9ment nul en anglais=F0=9F=98=8A=F0=9F=98=9B) :
  Instantiation error at gtk-handlers.ads : 1039
Subprogram must not be deeper than access type.

plus loin Gnat dit encore ceci :
 No candidate interpretations match the actuals:
expected type "handler" defined at gtk-marshaller.ads :395, instance at gtk=
-handlers :918 , instance at line 10.
Found type access to procedure "Stop_Program" defined at line 38.
=3D> in call to "to_marshaller" at gtk-handlers.ads :959, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :954, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :949, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :944, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :939, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :935, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :931, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :927, ainstance at line=
 10
=3D> in call to "to_marshaller" at gtk-handlers.ads :923, ainstance at line=
 10

voici mon code :=20

WITH Gtk.Main;             USE Gtk.Main;
WITH Gtk.Widget;         USE Gtk.Widget;
WITH Gtk.Window;        USE Gtk.Window;
WITH Gtk.Enums;          USE Gtk.Enums;
WITH Gtk.Button;           USE Gtk.Button;
WITH Gtk.Handlers;

Procedure Test is

Package P_Callback is new Gtk.Handlers.Callback (Gtk_Widget_Record);
USE P_Callback;

Procedure Stop_Program ( Emetteur : Gtk_Widget_Record'Class ) is
Pragma Unreferenced (Emetteur);
begin
Main_Quit;

end Stop_Program;

Win : Gtk_Window;
Bouton : Gtk_Button;

begin
Init;

Gtk_New (Win);
Win.Set_Default_Size (600,400);

Gtk_New (Bouton,"Le Bouton");


Win.Add (Bouton);

P_Callback.Connect (Bouton,"Clicked", To_marshaller (Stop_Program'Access));

Win.Show_All;
Main;
end Test;

Voila pour vous dire vrai je ne vois aucun probleme donc si quelqu'un pouva=
it m'expliquer ce qui cloche j'en serai vraiment ravi.

pour info je suis sur Windows10 et j'utilise la version Gnat 2020.