Hi Rajith, thanks a lot. That works even though I would have thought it
to be highly problematic in cluttermm. I'll write down what I did, it
may be useful for someone else in the future.

The signal handlers which initiate the animations on click and release
are in a semi-abstract base class from which I derive the actual
(reactive) elements of my UI. Hence no RefPtrs to them exist. The
problem is that grab_pointer requires to be passed a RefPtr to the actor
which will receive the events.

If I do a:
CustomBaseClass::on_click() {
        Clutter::grab_pointer( (Glib::RefPtr<CustomBaseClass> ) this );
        /* do stuff */
}

the RefPtr created from the this pointer to the class instance will be
decremented when on_click() is left. This causes the destruction of the
CustomBaseClass instance (to which no other RefPtr is pointing). So
that's not an option.

One workaround I thought about is to keep a "self" RefPtr which is
defined in the class constructor:

CustomBaseClass() {
        /* init stuff */
        self = (Glib::RefPtr<CustomBaseClass> ) this;
}

This could then be passed to grab_pointer. I thought that this would be
problem because keeping the RefPtr around would mean that the destructor
of the object will never be called. However, calling stage->remove_all()
[as is currently necessary to clean up properly] apparently causes all
children to be destroyed properly, even though RefPtr is still around.
(on second thought, it seems logical because the RefPtr is a member of
the object being destroyed)

-Bartek


Rajith Kalluraya wrote:
> Hi,
> 
> You can do a clutter_grab_pointer on the scrollbar widget in its button
> press handler. Motion events and the release events will be received by
> the scrollbar widget no matter where the mouse is.
> 
> Make sure you call clutter_ungrab_pointer in the release handler.
> 
> That should so the trick.
> 
> Cheers
> 
> 2009/6/19 Bartosz Kostrzewa <[email protected] <mailto:[email protected]>>
> 
>     I've got a little problem with catching release events. I have a
>     scrollbar widget the handle of which animates (slightly) on click and
>     release. The problem is that when using scrollbars one often mouses off
>     the scrollbar once the handle has been clicked and dragging is in
>     progress. This results in the consecutive release event not being caught
>     by the scrollbar handle because the pointer is not above it.
> 
>     Short of adding special signal handlers for the stage and every single
>     scrollbar on the stage, is there a way to make the release event
>     propagate to the scrollbar handle's on_release handler? IE: to announce
>     to clutter that this particular object is now globally reactive for this
>     particular event? (as the event should propagate even if the mouse
>     pointer is off-stage, for non-fullscreen applications)


-- 
To unsubscribe send a mail to [email protected]

Reply via email to