From 9bb68180b44093b7a925d3a47d017023590e0a68 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Tue, 14 Jan 2014 21:16:28 -0500 Subject: [PATCH] made mouse click logic ignore comments at runtime to allow clicks to be sent to proper objects that may be under the comments --- pd/src/g_editor.c | 7 ++++--- pd/src/g_graph.c | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index ea840b3c0..913d698c9 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -2782,6 +2782,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int shiftmod, runmode, altmod, doublemod = 0, rightclick; int x1=0, y1=0, x2=0, y2=0, clickreturned = 0; t_gobj *yclick = NULL; + t_object *ob; //fprintf(stderr,"MAIN canvas_doclick %d %d %d %d %d\n", xpos, ypos, which, mod, doit); @@ -2859,8 +2860,9 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, for (y = x->gl_list; y; y = y->g_next) { // check if the object wants to be clicked (we pick the topmost clickable) - if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2)) { - yclick = y; + if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2) && (ob = pd_checkobject(&y->g_pd))) { + if (ob->te_type != T_TEXT) // do not give clicks to comments during runtime + yclick = y; //fprintf(stderr," MAIN found clickable %d\n", clickreturned); } } @@ -2888,7 +2890,6 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, /* if in editmode click, fall here. */ if (y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2)) { - t_object *ob; /* check you're in the rectangle */ ob = pd_checkobject(&y->g_pd); if (rightclick) diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index 8c34610a9..51c60ac6c 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -1364,9 +1364,11 @@ static int graph_click(t_gobj *z, struct _glist *glist, else { int x1, y1, x2, y2; - /* check if the object wants to be clicked */ - if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2)) - clickme = y; + t_object *ob; + /* check if the object wants to be clicked and pick the topmost with the exception of the text (comment)*/ + if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2) && (ob = pd_checkobject(&y->g_pd))) + if (ob->te_type != T_TEXT) // do not give clicks to comments during runtime + clickme = y; //fprintf(stderr," found clickable %d\n", clickreturned); } } -- GitLab