Find path under mouse

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Find path under mouse

Daniel Kasak-4
Hi all. Reposting from the gtk-perl list ... no responses there ...

Back in gtk+-2.x, I had some code that could find the path underneath
the mouse ( I was looking for double-click events in a treeview in
this case ):

---

    my ( $self, $treeview, $event ) = @_;

    if ( $event->type eq '2button-press' ) {

        # A double-click event

        if ( $event->window == $treeview->get_bin_window ) {

            my ( $path, $column, $cell_x, $cell_y ) =
                $treeview->get_path_at_pos ( $event->x, $event->y );

---

Now I'm doing something similar in gtk+-3.x. I've set up an event
handler for keypress events, and I'm successfully catching the CTRL-C
keypress event. But I don't see immediately how to get the path /
position under the mouse ...

Dan
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find path under mouse

Anthony Ruth
If I understand correctly, you want to get the x and y value of the mouse
at the time when the keyboard event happens. You can either use
GdkDeviceManager to get the pointer and then get x and y from that, or
listen for motion_notify events on your treeview and keep track of x and y
values (I think this may be what you mean by path).

Anthony Ruth
NASA Space Technology Research Fellow
Condensed Matter Theory
University of Notre Dame

On Tue, Jun 20, 2017 at 1:21 AM, Daniel Kasak <[hidden email]>
wrote:

> Hi all. Reposting from the gtk-perl list ... no responses there ...
>
> Back in gtk+-2.x, I had some code that could find the path underneath
> the mouse ( I was looking for double-click events in a treeview in
> this case ):
>
> ---
>
>     my ( $self, $treeview, $event ) = @_;
>
>     if ( $event->type eq '2button-press' ) {
>
>         # A double-click event
>
>         if ( $event->window == $treeview->get_bin_window ) {
>
>             my ( $path, $column, $cell_x, $cell_y ) =
>                 $treeview->get_path_at_pos ( $event->x, $event->y );
>
> ---
>
> Now I'm doing something similar in gtk+-3.x. I've set up an event
> handler for keypress events, and I'm successfully catching the CTRL-C
> keypress event. But I don't see immediately how to get the path /
> position under the mouse ...
>
> Dan
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...