Re: capturing mouse dragged events



>How do I capture a mouse dragged event ?  I can capture both the mouse pressed
>and mouse released event from an eventbox signal.  I have tried the following 
>but it does not output the "Mouse Moved".  thks for any help.

you need to attach to GkdEventMotion, not GdkEventButton. The latter
is concerned with button press/release, the former is concerned with 
pointer motion:

bool MainDialog::on_motion_event (GdkEventMotion* event) {
     ...
     return TRUE;
}

note a typical stumbling block for handling this: computing
coordinates and distances. the pattern i typically use for this looks
like:


	a) in a button press event, store the event coordinates 
        b) in a motion event, compute the delta between the 
	     current stored coordinates and the event coordinates.
	     use that delta in some way. then store the new
	     event coordinates, replacing the old ones.
	c) in a button release event, call the motion event handler
	     again (because the last event of the drag may not
	     generate a motion event, on a button release)

--p



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