Re: pop up menu right clicking on a tree item



Giovanni Masullo wrote:
> can anyone tell me how i can capture the mouse
> right click on a tree item?
> i would like to do that to putting up a popup menu
> related to that item.

Hi Giovanni, for CTree (I guess you are using this?) attach to the "event"
signal, use gtk_clist_get_selection_info() to find the row and column, then use
gtk_ctree_get_node_nth() to find the node the user clicked on.

static gboolean
my_tree_event( GtkCTree *ctree, GdkEvent *ev, Mystuff *stuff )
{
        int row, column;

        if( ev->type == GDK_BUTTON_PRESS && ev->button.button == 3 &&
                gtk_clist_get_selection_info( GTK_CLIST( ctree ),
                        ev->button.x, ev->button.y, &row, &column ) ) {
                GtkCTreeNode *node = gtk_ctree_node_nth( ctree, row );

                ... popup menu for node
        }

        return( FALSE );
}

        gtk_signal_connect( GTK_OBJECT( ctree ), "event",
                GTK_SIGNAL_FUNC( my_tree_event ), stuff );

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]