Re: Double click precision....



i've seen on the FAQ  ( http://www.gtk.org/faq/#AEN505 )
a routine to catch double clicks...

But i don't understand to what do i have to connect the signal...
To the treeview (not working)  [CUT]

Well, definitely it is not true (well... not in general - it may not
work because of e.g. a bug) :-)

Hope I didn't mess anything up in the code by cutting.

Regards,
Waldek

=============================================
An example - which collapses || expands a row's children
on double click on parent. BTW, in my opinion, such
a functionality would be quite nice as default - but
it just *my* opinion .

=======

/** Part used in TreeView creation && initialization */

GtkWidget *treeView;
GtkTreeStore *treeStore;
// [...]

treeStore = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_POINTER);

/* Create a view */
treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(treeStore));

g_signal_connect(G_OBJECT(treeView), "button-press-event",

G_CALLBACK(m_cTreeViewPressed), this);

/** [..] adding columns, creating cell renderers and so on */

=================================================

/** callback - in my case it is a static member function
*  of a CFilterWindow class object, but it doesn't matter at all.....   */

gboolean CFilterWindow::m_cTreeViewPressed(GtkWidget * widget,
GdkEventButton *event,

gpointer data)
{
        GtkTreePath *treePath;
        GtkTreeViewColumn *treeColumn;
        GtkTreeModel *treeModel;
        GtkTreeIter iter;

        CFilterWindow *wnd = (CFilterWindow *) data;

        // [...] CUT a bit

        /* **********************
        *    LOOK HERE
        * ************************ */

        if (event->button==1 && event->type==GDK_2BUTTON_PRESS) //left
double click
        {
                gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(wnd->treeView),
                            (gint) event->x, (gint) event->y, &treePath,
&treeColumn, NULL, NULL);
                if (treePath!=NULL)
                {
                        treeModel =

gtk_tree_view_get_model(GTK_TREE_VIEW(wnd->treeView));
                        gtk_tree_model_get_iter(treeModel, &iter, treePath);

                    /**  expand  the row  if collapsed, collapse if expanded
*/
                        if
                            (!gtk_tree_view_row_expanded
                                        (GTK_TREE_VIEW(wnd->treeView),
treePath))

gtk_tree_view_expand_row(GTK_TREE_VIEW(wnd->treeView),

treePath, FALSE);
                        else
                            gtk_tree_view_collapse_row(

GTK_TREE_VIEW(wnd->treeView), treePath);
                     // other things
              }
        }
        return FALSE; // to allow resizing columns and so on...
}
=======================================================


----------------------------------------------------------------------
Poczta nowych mozliwosci >>> http://link.interia.pl/f16bc 





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