Re: missing button release event?



On Wed, 2012-07-11 at 14:07 +0100, Paul Emsley wrote:
> On 07/11/2012 12:05 AM, Damon Chaplin wrote:
> > On Tue, 2012-07-10 at 23:40 +0100, Paul Emsley wrote:
> >> On 10/07/12 20:33, Damon Chaplin wrote:
> >>> On Tue, 2012-07-10 at 17:48 +0100, Paul Emsley wrote:
> >>>> Hi,
> >>>>
> >>>> When I create a goocanvas
> >>>>
> >>>>       GtkWidget *canvas = goo_canvas_new();
> >>>>       GooCanvas *gc = GOO_CANVAS(canvas);
> >>>>
> >>>> I then attached callbacks to it...
> >>>>
> >>>>          ... other callbacks ...
> >>>>          g_signal_connect(G_OBJECT(goo_canvas_get_root_item(gc)),
> >>>>                   "button_release_event",
> >>>>                   G_CALLBACK(on_canvas_button_release), NULL);
> >>>>
> >>>>      This works fine almost all the time - however, there is one operation
> >>>> (a line addition) where the on_canvas_button_release callback doesn't
> >>>> get called (I added a print statement in it to check).  I can't think
> >>>> why it might not be being called.  Can you help?
> >>>>
> >>>> Cheers,
> >>>>
> >>>> Paul.
> >>>>
> >>>> p.s. code here: http://coot.googlecode.com/svn/trunk/lbg/lbg.cc
> >>> Are you creating an item underneath the mouse when the button is
> >>> pressed? The button release event may be being sent to that new item and
> >>> ignored.
> >>>
> >>> I can't think of any other reason at the moment. It would be handy if
> >>> GooCanvas had some debugging support for events - i.e. output where
> >>> events are being sent.
> >> Hi Damon,
> >>
> >> Thanks for your prompt reply.
> >>
> >> Yes, I am creating an item under the mouse (at least potentially).  The
> >> new line (a chemical bond, FWIW) changes (or can change) the text for
> >> the atom (under the cursor).
> >>
> >> I thought I had checked for that though by adding a button release
> >> callback specifically when text is created.  Maybe I missed one/some.  Hmm.
> >>
> >> Why is it that for this operation the callback is attached (or is at
> >> least potentially attached) to the new text item, but for most other
> >> mouse events (motion and button-down, for example) attaching callbacks
> >> to the canvas works fine?
> >>
> >> Is it more likely that the callback is attached to the text under the
> >> cursor that gets deleted or the text under the cursor that is newly
> >> created?  Maybe if I created a text group to handle this and added and
> >> deleted items from the group - would that be better do you think?
> > It shouldn't be that complicated.
> >
> > I think you just need to check all your button release callbacks and
> > make sure they only return TRUE when they handled the event.
> > If they return TRUE it stops the event from propagating up to parent
> > items.
> >
> 
> Hi Damon,
> 
> That's encouraging, thanks.
> 
> If I click on an item, drag to plain canvas and button-up, what should 
> get the button-up callback, canvas or item?

The item should get the button release event first. See below.


> If I click on an item (as as a result, the item is deleted), drag to 
> plain canvas and button up, what (if anything) received the button-up 
> callback? (In my case it seems nothing).

I think nothing gets the release event in this case.

I had forgotten about pointer grabs - when you click on an item it gets
an implicit pointer grab, and all further pointer events go to that item
until the button release. Currently if the item is deleted during that
time then those pointer events get ignored. Could this explain your
initial problem?

You might be able to use an explicit pointer grab by calling
goo_canvas_pointer_grab() to make sure you get all the events in that
case. Use the background item or one of the other items that doesn't get
deleted.

Damon




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