Re: Question about GdkEventButton in gtkmm-4.0

Kjell Ahlstedt via gtkmm-list <[email protected]> Fri, 7 Oct 2022 10:51:12 +0200
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============8903138843496682844==
Content-Type: multipart/alternative;
 boundary="------------UHIrVJ3NW065cuAcriJNY8ox"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------UHIrVJ3NW065cuAcriJNY8ox
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Use Gtk::GestureClick. Some examples:
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/menus/popup/examplewindow.cc
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/popover/examplewindow.cc

In most (perhaps all) situations where event signals have been used in 
gtkmm3, use one of the many subclasses of Gtk::EventController.
https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1EventController.html

Den 2022-10-06 kl. 23:57, skrev Aaron Scheinberg via gtkmm-list:
> Hello,
>
> I hope this is the right place for this, sorry if not!
>
> I'm trying to implement an example gtkmm 3.0 code in gtkmm 4.0 and ran 
> into a problem. The goal is to get the cursor's coordinates and what 
> type of click occurred when clicking on a button. In gtkmm 3.0, I 
> could use|GdkEventButton|, as in this example from thedocs 
> <https://developer-old.gnome.org/gtkmm-tutorial/unstable/gtkmm-tutorial.html#sec-xeventsignals>:
>
> |bool on_button_press(GdkEventButton* event); Gtk::Button 
> button("label"); button.signal_button_press_event().connect( 
> sigc::ptr_fun(&on_button_press) ); |
>
> But |GdkEventButton| seems to no longer exist or no longer be 
> accessible in gtkmm 4.0.
>
> There is a reference to GdkEvent API changes in the migration 
> documentation <https://docs.gtk.org/gtk4/migrating-3to4.html>, but I 
> still do not understand how to migrate that example code. Is anyone 
> more familiar or has any sort of related example?
>
> I've also posted this on stack overflow: 
> https://stackoverflow.com/questions/73979631/gdkeventbutton-when-migrating-from-gtkmm-3-0-to-gtkmm-4-0
>
> Thanks for your help,
> Aaron
>
>
--------------UHIrVJ3NW065cuAcriJNY8ox
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Use Gtk::GestureClick. Some examples:<br>
<a class="moz-txt-link-freetext" href="https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/menus/popup/examplewindow.cc">https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/menus/popup/examplewindow.cc</a><br>
<a class="moz-txt-link-freetext" href="https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/popover/examplewindow.cc">https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/popover/examplewindow.cc</a></p>
    <p>In most (perhaps all) situations where event signals have been
      used in gtkmm3, use one of the many subclasses of
      Gtk::EventController.<br>
<a class="moz-txt-link-freetext" href="https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1EventController.html">https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1EventController.html</a><br>
    </p>
    <div class="moz-cite-prefix">Den 2022-10-06 kl. 23:57, skrev Aaron
      Scheinberg via gtkmm-list:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+_8y7cZV7XHi-XW420rK-iTpfzZCUzd4PXS09DOhgr0hN6Uow@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hello,
        <div><br>
        </div>
        <div>I hope this is the right place for this, sorry if not!</div>
        <div><br>
        </div>
        <div>I'm trying to implement an example gtkmm 3.0 code in gtkmm
          4.0 and ran into a problem. <span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif">The goal is to get the cursor's
            coordinates and what type of click occurred when clicking on
            a button. </span><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif">In gtkmm 3.0, I could use</span><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif"> </span><code style="color:rgb(35,38,41);font-style:inherit;font-variant:inherit;font-weight:inherit;margin:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">GdkEventButton</code><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif">, as in this example from the</span><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif"> </span><a
href="https://developer-old.gnome.org/gtkmm-tutorial/unstable/gtkmm-tutorial.html#sec-xeventsignals"
            rel="nofollow noreferrer"
style="font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit"
            moz-do-not-send="true">docs</a><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif">:</span></div>
        <div><span
style="color:rgb(35,38,41);font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
            Sans&quot;,sans-serif"><br>
          </span></div>
        <div>
          <pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">bool on_button_press(GdkEventButton* event);
Gtk::Button button("label");
button.signal_button_press_event().connect( sigc::ptr_fun(&amp;on_button_press) );
</code></pre>
          <p
style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
Sans&quot;,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41)">But <code style="margin:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">GdkEventButton</code> seems
            to no longer exist or no longer be accessible in gtkmm 4.0.</p>
          <p
style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,&quot;system-ui&quot;,&quot;Segoe
            UI Adjusted&quot;,&quot;Segoe UI&quot;,&quot;Liberation
Sans&quot;,sans-serif;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41)">There
            is a reference to GdkEvent API changes in the <a
              href="https://docs.gtk.org/gtk4/migrating-3to4.html"
              rel="nofollow noreferrer"
style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit"
              moz-do-not-send="true">migration documentation</a>, but I
            still do not understand how to migrate that example code. Is
            anyone more familiar or has any sort of related example?</p>
        </div>
        <div>I've also posted this on stack overflow: <a
href="https://stackoverflow.com/questions/73979631/gdkeventbutton-when-migrating-from-gtkmm-3-0-to-gtkmm-4-0"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://stackoverflow.com/questions/73979631/gdkeventbutton-when-migrating-from-gtkmm-3-0-to-gtkmm-4-0</a></div>
        <div><br>
        </div>
        <div>Thanks for your help,</div>
        <div>Aaron</div>
      </div>
      <br>
      <br>
    </blockquote>
  </body>
</html>

--------------UHIrVJ3NW065cuAcriJNY8ox--

--===============8903138843496682844==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

--===============8903138843496682844==--