Re: Forwarding a button-press-event in HippoCanvas

On Sun, 2008-06-01 at 16:21 -0700, knipknap wrote:
> Hi,
> In a case where an empty container partly overlaps some other canvas
> items, I am trying to prevent the empty container from eating button-
> press-events.
> The way this currently works is that the button-press-event is caught
> by the empty box. Since that box doesn't handle the event, it is
> trying to forward the event to its parent, which is not the widget
> that really should fetch the event.
> Is there a way to forward the event to the corresponding canvas item
> when that item is partly hidden by an (empty) container?

Hmmm, you could get an effect likje that if you did something like,
in hippo-canvas-box.c, change:

        child = find_child_at_point(box, event->x, event->y);
        if (child != NULL) {
            set_release_pending (child, event->u.button.button, TRUE); 
            return hippo_canvas_item_process_event(child->public.item,
                                                   event, child->x, child->y);
        } else {
            return FALSE;

To something like:

       GSList *children = find_children_at_point(box, event->x, event->y);
       gboolean result = FALSE;

       for (l = children; l; l->next) {
            HippoCanvasItem *child = l->data;

            if (hippo_canvas_item_process_event(child->public.item,
                                                event, child->x, child->y) {
                 set_release_pending (child, event->u.button.button, TRUE);
                 result = TRUE;

       return result;

Disadvantages to this:

 - This is somewhat incompatible in hard to detect ways: if a button-press-event
   handler returns FALSE, then the widget will no longer "capture" the mouse 
   until. This means that if a widget only handles 'button-release', and not
   'button-press', it won't get the capturing behavior.

   I don't have a problem with that as a behavior *from scratch*, but I'm worried
   about it breaking existing code.

 - The "enter/leave" events will no longer match the button presses ... the 
   item underneath will get button presses without an enter/leave before hand.

So, I'm not really comfortable with that. A different approach would be to
add a 'hit-test' virtual-function/signal to HippoCanvasItem, so that an item
could be shaped rather than rectangular.

Can you be more specific about what you are trying to achieve?

- Owen


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