Re: Question about GdkEventButton in gtkmm-4.0

Aaron Scheinberg via gtkmm-list <[email protected]> Fri, 7 Oct 2022 09:13:15 -0700
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CA+_8y7cBy=9yBKSNOH6MNMJSVWDoD=9EBtv-mMwBbaUdpx49FQ@mail.gmail.com>
--===============4485761638841757843==
Content-Type: multipart/alternative; boundary="000000000000039c8905ea74178b"

--000000000000039c8905ea74178b
Content-Type: text/plain; charset="UTF-8"

Hi Kjell,

Thanks for the quick response - that was very helpful and I have my code
working now.

Best,
Aaron

On Fri, Oct 7, 2022 at 1:51 AM Kjell Ahlstedt <[email protected]>
wrote:

> 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 the docs
> <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
>
>
>

--000000000000039c8905ea74178b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Kjell,<div><br></div><div>Thanks for the quick response=
 - that was very helpful and I have my code working now.</div><div><br></di=
v><div>Best,</div><div>Aaron</div></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 7, 2022 at 1:51 AM Kjell Ahls=
tedt &lt;<a href=3D"mailto:[email protected]">[email protected]=
</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 =20
   =20
 =20
  <div>
    <p>Use Gtk::GestureClick. Some examples:<br>
<a href=3D"https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master=
/examples/book/menus/popup/examplewindow.cc" target=3D"_blank">https://gitl=
ab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/menus/po=
pup/examplewindow.cc</a><br>
<a href=3D"https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master=
/examples/book/popover/examplewindow.cc" target=3D"_blank">https://gitlab.g=
nome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/popover/exam=
plewindow.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 href=3D"https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1EventCont=
roller.html" target=3D"_blank">https://gnome.pages.gitlab.gnome.org/gtkmm/c=
lassGtk_1_1EventController.html</a><br>
    </p>
    <div>Den 2022-10-06 kl. 23:57, skrev Aaron
      Scheinberg via gtkmm-list:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <div dir=3D"ltr">Hello,
        <div><br>
        </div>
        <div>I hope this is the right place for this, sorry if not!</div>
        <div><br>
        </div>
        <div>I&#39;m trying to implement an example gtkmm 3.0 code in gtkmm
          4.0 and ran into a problem.=C2=A0<span>The goal is to get the cur=
sor&#39;s
            coordinates and what type of click occurred when clicking on
            a button.=C2=A0</span><span>In gtkmm 3.0, I could use</span><sp=
an>=C2=A0</span><code style=3D"color:rgb(35,38,41);font-style:inherit;font-=
variant:inherit;font-weight:inherit;margin:0px;border:0px;font-stretch:inhe=
rit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-sp=
ace:pre-wrap">GdkEventButton</code><span>, as in this example from the</spa=
n><span>=C2=A0</span><a href=3D"https://developer-old.gnome.org/gtkmm-tutor=
ial/unstable/gtkmm-tutorial.html#sec-xeventsignals" rel=3D"nofollow norefer=
rer" style=3D"font-family:inherit;font-style:inherit;font-variant:inherit;f=
ont-weight:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;l=
ine-height:inherit;vertical-align:baseline;box-sizing:inherit" target=3D"_b=
lank">docs</a><span>:</span></div>
        <div><span><br>
          </span></div>
        <div>
          <pre style=3D"margin-top:0px;border:0px;font-variant-numeric:inhe=
rit;font-variant-east-asian:inherit;font-stretch:inherit;vertical-align:bas=
eline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code s=
tyle=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertica=
l-align:baseline;box-sizing:inherit;background-color:transparent;white-spac=
e:inherit;border-radius:0px">bool on_button_press(GdkEventButton* event);
Gtk::Button button(&quot;label&quot;);
button.signal_button_press_event().connect( sigc::ptr_fun(&amp;on_button_pr=
ess) );
</code></pre>
          <p>But=C2=A0<code style=3D"margin:0px;border:0px;font-style:inher=
it;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-heigh=
t:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">=
GdkEventButton</code>=C2=A0seems
            to no longer exist or no longer be accessible in gtkmm 4.0.</p>
          <p>There
            is a reference to GdkEvent API changes in the=C2=A0<a href=3D"h=
ttps://docs.gtk.org/gtk4/migrating-3to4.html" rel=3D"nofollow noreferrer" s=
tyle=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;box-sizing:inherit" target=3D"_blank">=
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&#39;ve also posted this on stack overflow:=C2=A0<a href=3D"h=
ttps://stackoverflow.com/questions/73979631/gdkeventbutton-when-migrating-f=
rom-gtkmm-3-0-to-gtkmm-4-0" target=3D"_blank">https://stackoverflow.com/que=
stions/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>
  </div>

</blockquote></div>

--000000000000039c8905ea74178b--

--===============4485761638841757843==
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

--===============4485761638841757843==--