Re: mouse button event and gtkmm-4.0
Duncan Duncan via gtkmm-list <[email protected]> Mon, 26 Sep 2022 22:04:12 +0200
| Newsgroups | gmane.comp.gnome.gtkmm |
|---|---|
| Message-ID | <CAOT_Xmznz5RFoNka+6Dk2_bsOF5PQ1VaJFQRdH0ukmeYAMTtug@mail.gmail.com> |
--===============2988611002273296000==
Content-Type: multipart/alternative; boundary="000000000000aaf96105e99a081e"
--000000000000aaf96105e99a081e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Thanks!
so I just try quickly something like this. Exactly what i need.
auto mouse =3D Gtk::GestureClick::create();
mouse->set_propagation_phase(Gtk::PropagationPhase::CAPTURE);
mouse->set_button(GDK_BUTTON_PRIMARY);
add_controller(mouse);
mouse->signal_pressed().connect(sigc::mem_fun(*this, &Window::
on_mouse_key_pressed), false);
void on_mouse_key_pressed(int, double, double)
{
std::cout << "clic left mouse button" << std::endl;
}
Le lun. 26 sept. 2022 =C3=A0 19:29, Andrew Potter <[email protected]> a =
=C3=A9crit :
>
> On Mon, Sep 26, 2022 at 10:17 AM Duncan Duncan via gtkmm-list <
> [email protected]> wrote:
>
>> Could someone explain how to get event key mouse ?
>>
>>
> Hi,
> A question on the list a couple months ago prompted me to make this githu=
b
> gist:
>
> https://gist.github.com/talisein/f4f80167fa21f329f3db06a2730746f5
>
> In short, you need a Gtk::GestureClick event controller. The current gtkm=
m
> documentation is at
> https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1GestureClick.html
>
> Unfortunately google doesn't like returning the gitlab pages links yet.
>
--000000000000aaf96105e99a081e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks!=C2=A0<br><div><br></div><div>so I just try quickly=
something like this. Exactly what i need.</div><div><br></div><div><div st=
yle=3D"background-color:rgb(1,22,39);font-family:"Droid Sans Mono"=
;,"monospace",monospace;font-size:14px;line-height:19px;white-spa=
ce:pre"><div style=3D"color:rgb(214,222,235)"><span style=3D"color:rgb(199,=
146,234)">auto</span> <span style=3D"color:rgb(197,228,120)">mouse</span> <=
span style=3D"color:rgb(199,146,234)">=3D</span> Gtk::<span style=3D"color:=
rgb(197,228,120)">GestureClick</span>::<span style=3D"color:rgb(130,170,255=
)">create</span>();</div><div style=3D"color:rgb(214,222,235)"><span style=
=3D"color:rgb(197,228,120)">mouse</span><span style=3D"color:rgb(130,170,25=
5)">-></span><span style=3D"color:rgb(130,170,255)">set_propagation_phas=
e</span>(Gtk::<span style=3D"color:rgb(197,228,120)">PropagationPhase</span=
>::<span style=3D"color:rgb(197,228,120)">CAPTURE</span>);</div><div style=
=3D"color:rgb(214,222,235)"><span style=3D"color:rgb(197,228,120)">mouse</s=
pan><span style=3D"color:rgb(130,170,255)">-></span><span style=3D"color=
:rgb(130,170,255)">set_button</span>(<span style=3D"color:rgb(127,219,202)"=
>GDK_BUTTON_PRIMARY</span>);</div><div style=3D"color:rgb(214,222,235)"><sp=
an style=3D"color:rgb(130,170,255)">add_controller</span>(<span style=3D"co=
lor:rgb(197,228,120)">mouse</span>);</div><div style=3D""><span style=3D"co=
lor:rgb(197,228,120)">mouse</span><span style=3D"color:rgb(130,170,255)">-&=
gt;</span><span style=3D"color:rgb(130,170,255)">signal_pressed</span><font=
color=3D"#d6deeb">().</font><span style=3D"color:rgb(130,170,255)">connect=
</span><font color=3D"#d6deeb">(sigc::</font><span style=3D"color:rgb(130,1=
70,255)">mem_fun</span><font color=3D"#d6deeb">(</font><span style=3D"color=
:rgb(199,146,234)">*</span><span style=3D"color:rgb(127,219,202)">this</spa=
n><font color=3D"#d6deeb">, </font><span style=3D"color:rgb(199,146,234)">&=
amp;</span><font color=3D"#c5e478">Window</font><font color=3D"#d6deeb">::<=
/font><span style=3D"color:rgb(130,170,255)">on_mouse_key_pressed</span><fo=
nt color=3D"#d6deeb">), </font><span style=3D"color:rgb(130,170,255)">false=
</span><font color=3D"#d6deeb">);</font></div><div style=3D"color:rgb(214,2=
22,235)"><br></div><div style=3D"color:rgb(214,222,235)"><div style=3D"line=
-height:19px"><div><span style=3D"color:rgb(199,146,234)">void</span> <span=
style=3D"color:rgb(130,170,255)">on_mouse_key_pressed</span>(<span style=
=3D"color:rgb(199,146,234)">int</span>, <span style=3D"color:rgb(199,146,23=
4)">double</span>, <span style=3D"color:rgb(199,146,234)">double</span>)</d=
iv><div>{</div><div> std::<span style=3D"color:rgb(197,228,120)">cout</spa=
n> <span style=3D"color:rgb(130,170,255)"><<</span> <span style=3D"co=
lor:rgb(217,245,221)">"</span><span style=3D"color:rgb(236,196,141)">c=
lic left mouse button</span><span style=3D"color:rgb(217,245,221)">"</=
span> <span style=3D"color:rgb(130,170,255)"><<</span> std::<span sty=
le=3D"color:rgb(130,170,255)">endl</span>;</div><div>}</div></div></div></d=
iv></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gma=
il_attr">Le=C2=A0lun. 26 sept. 2022 =C3=A0=C2=A019:29, Andrew Potter <<a=
href=3D"mailto:[email protected]">[email protected]</a>> a =C3=A9crit=
=C2=A0:<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"><div dir=
=3D"ltr"><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_att=
r">On Mon, Sep 26, 2022 at 10:17 AM Duncan Duncan via gtkmm-list <<a hre=
f=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a=
>> 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"><di=
v dir=3D"ltr">Could someone explain how to get=C2=A0 event key mouse ?<br>
</div><br></blockquote><div><br></div><div>Hi,</div><div>A question on the =
list a couple months ago prompted me to make this github gist:</div><div><b=
r></div><div><a href=3D"https://gist.github.com/talisein/f4f80167fa21f329f3=
db06a2730746f5" target=3D"_blank">https://gist.github.com/talisein/f4f80167=
fa21f329f3db06a2730746f5</a></div><div><br></div><div>In short, you need a =
Gtk::GestureClick event controller. The current gtkmm documentation is at <=
a href=3D"https://gnome.pages.gitlab.gnome.org/gtkmm/classGtk_1_1GestureCli=
ck.html" target=3D"_blank">https://gnome.pages.gitlab.gnome.org/gtkmm/class=
Gtk_1_1GestureClick.html</a></div><div><br></div><div>Unfortunately google =
doesn't like returning the gitlab pages links yet.<br></div></div></div=
>
</blockquote></div>
--000000000000aaf96105e99a081e--
--===============2988611002273296000==
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
--===============2988611002273296000==--