Re: GtkCellRendererToggle toggles when clicking on other cell renderers in same column



Hi,

I understand why this behavior occurs; I do realize that it would be
what is wanted in most circumstances. In this particular case,
selecting the row causes one action to occur and toggling the checkbox
causes another action to occur. Because all of the cell renderers are
considered one activatable entity, it is very difficult to select the
row without toggling the checkbox; the user would have to click in
another column. I considered having the GtkCellRendererToggle in a
separate column, but this is not acceptable either, because the
checkbox, pixbuf, and text must all be indented together when a row in
the tree is expanded.

I suppose overriding the activate method is probably going to be the
easiest way of doing this. I'm not looking forward to it; it seems
like there should be a more elegant solution to the problem.

Thanks a lot for your help.

On Wed, Aug 12, 2009 at 12:16 AM, Kristian Rietveld<kris gtk org> wrote:
Hello,

On Wed, Aug 12, 2009 at 2:32 AM, Grumpy
Buffalo<grumpybuffalo+gtk gmail com> wrote:
Hi, I am working on a C++ GTK project. I have a GtkTreeView containing
several columns. In the first column, I have packed in 3 cell
renderers - the first, a GtkCellRendererToggle; the second, a
GtkCellRendererPixbuf; the third, a GtkCellRendererText. Everything
works fine, except that clicking on the text in the
GtkCellRendererText causes the 'toggled' event to fire on the

This is happening because the column that you have created has a
single activatable cell renderer.  The column is then seen as a single
activatable entity.  (It is more clearly seen in keyboard navigation,
when this column gets focus it will draw the focus indicator around
all cell renderers instead of around a single cell renderer, again
because there is only a single cell renderer that can be activated).
Often this is the behavior you want, for example when you pack a text
renderer next to the toggle renderer.  It will act the same as a
regular toggle button which also allows clicking on the text.

GtkCellRendererToggle. This is no good in this particular case. Is

Why exactly is it no good in this case?  The contents packed together
in a column surely belong together in some way?


there any way, besides keeping track of where the mouse pointer is, to
determine whether the user clicked on the checkbox itself or another
cell renderer in the same column? Thanks in advance for any ideas.

The only way I can think of so quickly to work around this is probably
to subclass GtkCellRendererToggle and override the activate method to
check the event coordinates that are provided with the cell_area or
background_area coordinates. (GtkCellRendererToggle itself does not do
this and immediately emits the toggled signal).


regards,

-kris.


-- 
Grumpy Buffalo



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