Re: Obtaining a location on a Drawing Area via a mouse click.
- From: Billy Patton <bpatton dal asp ti com>
- To: Colin Thomas <colin designresources co uk>
- Cc: gtk-list gnome org
- Subject: Re: Obtaining a location on a Drawing Area via a mouse click.
- Date: Mon, 15 Jan 2001 06:53:29 -0600
Here's my mouse motion sub that will get what you need :)
gint motion_notify_event(GtkWidget *widget,GdkEventMotion *event)
{
point_t pt;
GdkModifierType state;
gchar buffer[64];
static gint message_id = INT_MIN;
char *cname = NULL;
if (event->is_hint)
gdk_window_get_pointer (event->window, &pt.x, &pt.y, &state);
else
{
pt.x = event->x;
pt.y = event->y;
state = event->state;
}
if (fcellp) cname = fcellp->name;
pt.x = (int)((pt.x * scale) + shiftX);
pt.y = canvas_y - pt.y;
pt.y = (int)((pt.y * scale) + shiftY);
RoundPt(&pt,50);
sprintf(buffer,"%s , XY : %d,%d",(cname)?cname:"NO CELL SELECTED",pt.x,pt.y);
if (message_id NE INT_MIN)
gtk_statusbar_remove(GTK_STATUSBAR(widget)
,context_id
,message_id);
message_id = gtk_statusbar_push(GTK_STATUSBAR(widget)
,context_id
,buffer);
return TRUE;
}
Colin Thomas wrote:
> Hi,
>
> I would like to be able to click on a Drawing area and extract
> the cursors position, and possibly drag-select over its suface.
>
> Are there any tutorials on this?
>
> I have connected a function to the button release on the Drawing
> Area (see below), this does not seem to trigger the function call,
>
> gtk_signal_connect (GTK_OBJECT (guiDrawingArea), "button_press_event",
> GTK_SIGNAL_FUNC (on_guiDrawingArea_button_press_event),
> NULL);
>
> But even if I managed to get the function call to execute, from where do
> I extract the cursor's location..
>
> I look forward to your collective wisdom..
>
> Many thanks in advance..
>
> Colin Thomas.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | Colin Thomas.
> | Email : colin designresources co uk
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]