Commit a20427d0 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Retracing steps to enable holistic mouse action tracking via glist_grab

* Lots of debugging stuff lying around.

* A significant rewrite of the prior iemgui numbox behavior to capitalize on the exclusive grab opportunity.
parent 85aaebc9
......@@ -2967,9 +2967,7 @@ function gui_text_set_mynumbox (cid, tag, text, active) {
text = text.trim();
e.textContent = "";
text_to_tspans(cid, e, text);
if (active === 2) {
e.classList.remove("activated");
} else if (active === 1) {
if (active === 1) {
e.classList.add("activated");
} else {
e.classList.remove("activated");
......
......@@ -182,8 +182,8 @@ typedef struct _my_numbox
{
t_iemgui x_gui;
t_clock *x_clock_reset;
t_clock *x_clock_wait;
double x_val;
double x_oldval;
double x_min;
double x_max;
double x_k;
......@@ -197,15 +197,15 @@ typedef struct _my_numbox
int x_num_fontsize;/* font size for the number only that should
automatically adjust to the box size */
int x_focused; /* helps us determine when and how we are editing value
0 no focus, 1 keyboard focus, 2 mouse focus */
0 no focus, 1 mouse focus, 2 keyboard focus without
the trailing '>', and, 3 keyboard focus with the
trailing '>' */
int x_log_height;
int x_drawstyle; /* 0 default, 1 just frame, 2, just arrow, 3 number only */
int x_shiftclick; /* used to keep track how the number was originally focused
so that when it is shift-clicked, it is in append mode, and
when focused without the shift, it is operating in the old
mode */
int x_dragged; /* whether the object has been dragged since it was clicked
we use this to fine-tune the exclusive focus */
} t_my_numbox;
extern int sys_noloadbang;
......
......@@ -3688,13 +3688,13 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
canvas_undo_already_set_move = 0;
// if keyboard was grabbed, notify grabber and cancel the grab
if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn)
if (doit > 0 && x->gl_editor->e_grab && x->gl_editor->e_keyfn)
{
(* x->gl_editor->e_keyfn) (x->gl_editor->e_grab, 0);
glist_grab(x, 0, 0, 0, 0, 0, 0, 0);
}
if (doit && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
if (doit > 0 && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
sys_getrealtime() - canvas_upclicktime < DCLICKINTERVAL)
doublemod = 1;
x->gl_editor->e_lastmoved = 0;
......@@ -3703,7 +3703,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
to check for any regressions as this is needed to re-check
scrollbar after something was created->startmotion->clicked
to let go */
if (doit)
if (doit > 0)
{
//fprintf(stderr,"doit %d\n", x->gl_editor->e_onmotion);
if (x->gl_editor->e_onmotion == MA_MOVE)
......@@ -3728,6 +3728,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
x->gl_editor->e_grab = 0;
x->gl_editor->e_onmotion = MA_NONE;
post("canvas_doclick e_onmotion=0");
}
}
//post("click %d %d %d %d", xpos, ypos, which, mod);
......@@ -3811,7 +3812,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
/* check for ctrlmod click and give a warning once in the console that
the hotkey for temporary runmode has changed */
if (!ctrl_runmode_warned && ctrlmod && !rightclick && doit) {
if (!ctrl_runmode_warned && ctrlmod && !rightclick && doit > 0) {
post("\nwarning: The hotkey for temporary run mode has changed. "
"Please press Alt instead of Ctrl to enable it.\n");
ctrl_runmode_warned = 1;
......@@ -3826,7 +3827,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
// we are clicking and making a (de)selection
// (only if we are not hovering above an outlet)
if (doit)
if (doit > 0)
{
if (glist_isselected(x, y))
glist_deselect(x, y);
......@@ -3853,7 +3854,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
if (in_text_resizing_hotspot)
{
// ...and we are clicking...
if (doit)
if (doit > 0)
{
// ...select the object
if (!glist_isselected(x, y) ||
......@@ -3941,7 +3942,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
//post("Outlet found...");
//...and we are clicking on it
if (doit)
if (doit > 0)
{
//fprintf(stderr,"start connection\n");
int issignal = obj_issignaloutlet(ob, closest);
......@@ -4022,7 +4023,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
//post("Comb the Desert!");
canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
canvas_check_nlet_highlights(x);
if (doit)
if (doit > 0)
goto nooutletafterall;
}
}
......@@ -4076,12 +4077,12 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
canvas_check_nlet_highlights(x);
}
if (doit)
if (doit > 0)
goto nooutletafterall;
}
}
/* not in an outlet; select and move */
else if (doit)
else if (doit > 0)
{
t_rtext *rt;
/* check if the box is being text edited */
......@@ -4154,7 +4155,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
}
else if (in_text_resizing_hotspot) /* red gop rectangle */
{
if (doit)
if (doit > 0)
{
x->gl_editor->e_onmotion = MA_RESIZE;
x->gl_editor->e_xwas = x1;
......@@ -4217,7 +4218,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
if (area * area >= 50 * dsquare) continue;
if ((lx2-lx1) * (fx-lx1) + (ly2-ly1) * (fy-ly1) < 0) continue;
if ((lx2-lx1) * (lx2-fx) + (ly2-ly1) * (ly2-fy) < 0) continue;
if (doit)
if (doit > 0)
{
glist_selectline(glist2, oc,
canvas_getindex(glist2, &t.tr_ob->ob_g), t.tr_outno,
......@@ -4283,7 +4284,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
// end jsarlo
if (x->gl_editor->e_onmotion != MA_SCROLL)
canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
if (doit)
if (doit > 0)
{
if (!shiftmod &&
(x->gl_editor->e_selection || x->gl_editor->e_selectedline))
......@@ -5290,6 +5291,7 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
canvas_selectinrect(x, lox, loy, hix, hiy);
gui_vmess("gui_canvas_hide_selection", "x", x);
x->gl_editor->e_onmotion = MA_NONE;
post("canvas_do_region MA_NONE");
}
else
{
......@@ -5305,6 +5307,7 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
void canvas_mouseup(t_canvas *x,
t_floatarg fxpos, t_floatarg fypos, t_floatarg fwhich)
{
post("CANVAS_MOUSEUP");
//if (toggle_moving == 1) {
// toggle_moving = 0;
// sys_vgui("pdtk_toggle_xy_tooltip .x%zx %d\n", x, 0);
......@@ -5346,7 +5349,8 @@ void canvas_mouseup(t_canvas *x,
canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
}
if (x->gl_editor->e_onmotion != MA_CONNECT ||
if ((x->gl_editor->e_onmotion != MA_CONNECT &&
x->gl_editor->e_onmotion != MA_PASSOUT) ||
x->gl_editor->e_onmotion == MA_CONNECT && !glob_shift)
{
//fprintf(stderr,"releasing shift during connect without "
......@@ -5360,13 +5364,23 @@ void canvas_mouseup(t_canvas *x,
}
x->gl_editor->e_onmotion = MA_NONE;
post("mouseup MA_NONE");
}
//fprintf(stderr,"canvas_mouseup -> canvas_doclick %d\n", which);
/* this is to ignore scrollbar clicks from within tcl and is
unused within nw.js 2.x implementation and onward */
unused within nw.js 2.x implementation and onward. here,
we use doit = -1 to signify mouseup */
//if (canvas_last_glist_mod == -1) {
post("...broadcasting onmotion=%d", x->gl_editor->e_onmotion);
if (x->gl_editor->e_onmotion == MA_PASSOUT)
{
int clickreturned = gobj_click(
x->gl_editor->e_grab, x, xpos, ypos, 0, 0, 0, -1);
post("clickreturned=%d", clickreturned);
}
canvas_doclick(x, xpos, ypos, 0,
(glob_shift + glob_ctrl*2 + glob_alt*4), 0);
(glob_shift + glob_ctrl*2 + glob_alt*4), -1);
//}
// now dispatch to any click listeners
canvas_dispatch_mouseclick(0., xpos, ypos, which);
......@@ -5591,9 +5605,37 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
// set the shared variable for broadcasting of keypresses to key et al. objects
t_atom at[2];
// 2020-10-04 ico@vt.edu: we are here changing the order of broadcasting
// key presses to grabbed objects first, and only then to all bound objects
// this change should be heavily scrutinized as it may introduce subtle
// and not so subtle regressions. I am here introducing it becuase doing so
// allows us to have some really nice flexibility in respect to grabbed objects.
// For instance, by allowing grabbed events to propagate first, objects like
// iemgui numbox and gatom can grab exclusive hold of key presses in select cases
// before such events propagate to other bound elements. So, here
// we do grabbed keynameafn here for key presses and releases
if (x && x->gl_editor && x->gl_editor->e_grab)
{
// as per vanilla behavior, we first send keynums, then keynames
if (x->gl_editor->e_keyfn && keynum && focus && down)
(* x->gl_editor->e_keyfn)
(x->gl_editor->e_grab, (t_float)keynum);
// this takes care of both keyname presses and releases
// because we don't discriminate between the down states
// as we used to...
if (x->gl_editor->e_keynameafn && gotkeysym && focus)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
(* x->gl_editor->e_keynameafn) (x->gl_editor->e_grab, 0, 2, at);
}
}
// now broadcast key press to key et al. objects
// ico@vt.edu 20200918: only do so if we do not have an object
// 2020-10-05 ico@vt.edu: only do so if we do not have an object
// that has grabbed the keyboard exclusively, such as gatom or iemgui numbox
post("canvas_key exclusive=%d", (x && x->gl_editor ? x->gl_editor->exclusive : 0));
if (!x || !x->gl_editor || !x->gl_editor->e_grab || !x->gl_editor->exclusive)
{
if (!autorepeat)
......@@ -5628,41 +5670,15 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
if (!x || !x->gl_editor)
return;
// we need to do grabbed keynameafn here for key releases
if (x && x->gl_editor && x->gl_editor->e_grab && !down)
{
if (x->gl_editor->e_keynameafn && gotkeysym && focus)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
(* x->gl_editor->e_keynameafn) (x->gl_editor->e_grab, 0, 2, at);
}
}
if (x && down)
{
/* cancel any dragging action */
if (x->gl_editor->e_onmotion == MA_MOVE)
x->gl_editor->e_onmotion = MA_NONE;
/* if an object has "grabbed" keys just send them on
but deal with key release above outside this loop */
if (x->gl_editor->e_grab)
{
if (x->gl_editor->e_keyfn && keynum && focus)
(* x->gl_editor->e_keyfn)
(x->gl_editor->e_grab, (t_float)keynum);
if (x->gl_editor->e_keynameafn && gotkeysym && focus)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
(* x->gl_editor->e_keynameafn) (x->gl_editor->e_grab, 0, 2, at);
}
}
/* if a text editor is open send the key on, as long as
it is either "real" (has a key number) or else is an arrow key. */
else if (x->gl_editor->e_textedfor && focus && (keynum
if (!x->gl_editor->e_grab && x->gl_editor->e_textedfor && focus && (keynum
|| !strcmp(gotkeysym->s_name, "Up")
|| !strcmp(gotkeysym->s_name, "Down")
|| !strcmp(gotkeysym->s_name, "Left")
......@@ -5799,6 +5815,7 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg fmod)
{
static t_symbol *mousemotionsym;
post("CANVAS_MOTION=%d", x->gl_editor->e_onmotion);
//fprintf(stderr,"motion %d %d %d %d\n",
// (int)xpos, (int)ypos, (int)fmod, canvas_last_glist_mod);
//fprintf(stderr,"canvas_motion=%d\n",x->gl_editor->e_onmotion);
......
......@@ -368,6 +368,10 @@ void glist_retext(t_glist *glist, t_text *y)
}
}
// 2020-10-05 ico@vt.edu:
// exclusive flag only applies to keyboard events (keyfn and keynameafn)
// as of right now I cannot think of a scenario where mouse motion should be
// exclusive to a single object.
void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn keyfn,
t_glistkeynameafn keynameafn, int xpos, int ypos, int exclusive)
{
......@@ -389,10 +393,10 @@ void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn ke
// only do so if e_grab is not null
int glist_grab_exclusive(t_glist *x, int exclusive)
{
if (x->gl_editor->e_grab)
t_glist *x2 = glist_getcanvas(x);
if (x2->gl_editor->e_grab)
{
t_glist *x2 = glist_getcanvas(x);
if (exclusive != 0 || exclusive != 1) return(1);
if (exclusive != 0 && exclusive != 1) return(1);
x2->gl_editor->exclusive = exclusive;
return(0);
}
......
......@@ -27,43 +27,31 @@ t_widgetbehavior my_numbox_widgetbehavior;
/*static*/ t_class *my_numbox_class;
// forward declarations
static void my_numbox_set_change(t_my_numbox *x, t_floatarg f);
static void my_numbox_remove_grab(t_my_numbox *x);
static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy);
static void my_numbox_ftoa(t_my_numbox *x , int append);
static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av);
static void my_numbox_tick_reset(t_my_numbox *x)
{
//post("tick_reset\n");
if(x->x_gui.x_change && x->x_gui.x_glist)
my_numbox_remove_grab(x);
if(x->x_gui.x_changed && x->x_gui.x_glist)
{
//post(" success\n");
my_numbox_set_change(x, 0);
my_numbox_ftoa(x, 0);
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0);
x->x_focused = 0;
}
static void my_numbox_tick_wait(t_my_numbox *x)
{
//post("tick_wait\n");
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
// to enable ability to change values using arrow keys (only when focused)
static void my_numbox_set_change(t_my_numbox *x, t_floatarg f)
// change the grab state depending on the current level of focus
// 0 = no focus and therefore no grab
// 1 = only mouse focus
// 2 = exclusive keyboard and mouse focus
static void my_numbox_remove_grab(t_my_numbox *x)
{
if (f == 0 && x->x_gui.x_change != 0)
{
x->x_gui.x_change = 0;
//pd_unbind(&x->x_gui.x_obj.ob_pd, numbox_keyname_sym_a);
}
else if (f == 1 && x->x_gui.x_change != 1)
{
x->x_gui.x_change = 1;
//pd_bind(&x->x_gui.x_obj.ob_pd, numbox_keyname_sym_a);
}
x->x_focused = 0;
glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0);
}
void my_numbox_clip(t_my_numbox *x)
......@@ -156,7 +144,8 @@ static void my_numbox_ftoa(t_my_numbox *x, int append)
static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
{
t_my_numbox *x = (t_my_numbox *)client;
post("my_numbox_draw_update focused=%d changed=%d emptybuf=%d",
x->x_focused, x->x_gui.x_changed, x->x_buf[0] ? 0 : 1);
// we cannot ignore this call even if there is no change
// since that will mess up number highlighting while editing
// the code is left here as it is similar to other iemguis
......@@ -164,31 +153,38 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
// if (!x->x_gui.x_changed) return;
if (!glist_isvisible(glist)) return;
if(x->x_gui.x_change && x->x_buf[0])
// if we are activated (focused)
if(x->x_focused && x->x_buf[0])
{
//post("draw_update 1 : focused=%d", x->x_focused);
char *cp=x->x_buf;
int sl = strlen(x->x_buf);
if (x->x_focused == 1)
// if we have been typing (focused == 2)
if (x->x_focused == 3)
{
x->x_buf[sl] = '>';
x->x_buf[sl+1] = 0;
} else if (x->x_focused == 2) {
// this is triggered when one presses return while retaining the focus of the number
// so, we make sure to subtract the '>' that has disappeared and adjust visible digits
// accordingly below
// the following two options are triggered when one presses return while retaining
// the focus. so, we make sure to subtract the '>' that should dissappear, and adjust
// visible digits accordingly below
if (x->x_gui.x_changed == 2)
{
// if we pressed enter while having a value outside the min/max bounds
// clip the value before displaying it
my_numbox_ftoa(x, 0);
sl = strlen(x->x_buf);
post("changed and clipped");
x->x_buf[sl] = 0;
//post("changed and clipped");
}
else
{
// otherwise, display it as-is without the '>'
x->x_buf[sl] = 0;
sl--;
}
}
// now update the object, retaining its activated state (last argument)
if(sl >= x->x_gui.x_w)
cp += sl - x->x_gui.x_w + 1;
gui_vmess("gui_text_set_mynumbox", "xxsi",
......@@ -196,30 +192,38 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
x,
cp,
1);
// here we check that we are not in the focused mode 2 that has this already taken care of above
if (x->x_focused != 2)
x->x_buf[sl] = 0;
}
else
{
//if (!x->x_focused || x->x_focused == 2)
//post("draw_update 2: x->x_buf=<%s> focused=%d change=%d", x->x_buf, x->x_focused, x->x_gui.x_change);
if (!x->x_buf[0] && x->x_focused == 1 && x->x_gui.x_change == 1)
// here we capture several conditions:
//post("draw_update 2: x->x_buf=<%s> focused=%d change=%d",
// x->x_buf, x->x_focused, x->x_gui.x_change);
if (!x->x_buf[0] && x->x_focused == 3)
{
// 1st condition: we are still typing into the number box and have deleted the
// last digit,so we draw only the '>'
x->x_buf[0] = '>';
x->x_buf[1] = 0;
}
else
{
// 2nd condition: we replace the x->x_buf with the last stored value
// e.g. when we are timing out and therefore losing focus and the
// value is reverting to its stored one
my_numbox_ftoa(x, 0); /* mmm... side-effects */
}
// then draw the object based on its focus. Here we also check for special case
// where we have been selected in edit mode and are toplevel in which case even
// if we are not activated, our number should be still colored as activated.
gui_vmess("gui_text_set_mynumbox", "xxsi",
glist_getcanvas(glist),
x,
x->x_buf,
x->x_gui.x_selected == glist_getcanvas(glist) &&
!x->x_gui.x_change && x->x_gui.x_glist == glist_getcanvas(glist) ?
2 : (x->x_gui.x_change ? 1 : 0));
!x->x_focused && x->x_gui.x_glist == glist_getcanvas(glist) ?
0 : (x->x_focused ? 1 : 0));
x->x_buf[0] = 0; /* mmm... more side-effects... no clue why we'd need
to mutate a struct member in order to draw stuff */
}
......@@ -315,7 +319,7 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
int issel = x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas;
if(x->x_gui.x_selected && x->x_gui.x_change)
{
my_numbox_set_change(x, 0);
x->x_focused = 0;
clock_unset(x->x_clock_reset);
x->x_buf[0] = 0;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
......@@ -356,7 +360,7 @@ static void my_numbox__motionhook(t_scalehandle *sh,
if (sh->h_scale)
{
t_my_numbox *x = (t_my_numbox *)(sh->h_master);
x->x_focused = 2;
//x->x_focused = 1;
//int dx = (int)mouse_x - sh->h_offset_x;
int dy = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_X) ? 0 :
(int)mouse_y - sh->h_offset_y;
......@@ -464,9 +468,9 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b)
t_symbol *srl[3];
iemgui_save(&x->x_gui, srl, bflcol);
if(x->x_gui.x_change)
if(x->x_focused)
{
my_numbox_set_change(x, 0);
my_numbox_remove_grab(x);
clock_unset(x->x_clock_reset);
x->x_gui.x_changed = 1;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
......@@ -529,7 +533,7 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner)
iemgui_properties(&x->x_gui, srl);
if(x->x_gui.x_change)
{
my_numbox_set_change(x, 0);
my_numbox_remove_grab(x);
clock_unset(x->x_clock_reset);
x->x_gui.x_changed = 1;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
......@@ -614,30 +618,33 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
{
x->x_focused = 2;
double k2=1.0;
int old = x->x_val;
if(x->x_gui.x_finemoved)
k2 = 0.01;
if(x->x_lin0_log1)
x->x_val *= pow(x->x_k, -k2*dy);
else
x->x_val -= k2*dy;
my_numbox_clip(x);
if (old != x->x_val)
post("my_numbox_motion");
if (x->x_focused == 1)
{
x->x_gui.x_changed = 1;
my_numbox_ftoa(x, 0);
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
my_numbox_bang(x);
// if we have clicked and have started dragging, this means we want to
// change number by dragging, so here we disable the exclusive nature
// of glist_grab
glist_grab_exclusive(x->x_gui.x_glist, 0);
double k2=1.0;
int old = x->x_val;
if(x->x_gui.x_finemoved)
k2 = 0.01;
if(x->x_lin0_log1)
x->x_val *= pow(x->x_k, -k2*dy);
else
x->x_val -= k2*dy;
my_numbox_clip(x);
if (old != x->x_val)
{
x->x_gui.x_changed = 1;
my_numbox_ftoa(x, 0);
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
my_numbox_bang(x);
}
clock_unset(x->x_clock_reset);
clock_delay(x->x_clock_reset, 3000);
}
clock_unset(x->x_clock_reset);
clock_delay(x->x_clock_reset, 3000);
// if we have clicked and have started dragging, this means we don't necessarily
// want to type into the box but change number by dragging, so here we disable
// the exclusive nature of glist_grab
glist_grab_exclusive(x->x_gui.x_glist, 0);
}
// this is called whenever there is a mousedown with left mouse button on top of the object
......@@ -645,9 +652,10 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{
// by default we have an exclusive grab (this may have to be done better...)
post("my_numbox_click: is this even being used at all other than below?");
glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
(t_glistmotionfn)my_numbox_motion, my_numbox_key, my_numbox_list, xpos, ypos, 1);
(t_glistmotionfn)my_numbox_motion, 0, my_numbox_list,
(t_floatarg)xpix, (t_floatarg)ypix, 0);
}
// this one gets called on both mouse down and mouse up (doit reports the mouse state)
......@@ -655,13 +663,15 @@ static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit)
{
post("my_numbox_newclick %d", doit);
t_my_numbox* x = (t_my_numbox *)z;
if(doit)
if (doit == 1)
{
//printf("newclick doit\n");
post("...my_numbox_newclick calling my_numbox_click...");
my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
(t_floatarg)shift, 0, (t_floatarg)alt);
if(shift)
if (shift)
{
x->x_gui.x_finemoved = 1;
x->x_shiftclick = 1;
......@@ -671,31 +681,73 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
x->x_gui.x_finemoved = 0;
x->x_shiftclick = 0;
}
if(!x->x_gui.x_change)
// if we are clicking on the object for the first time and are
// about to focus onto it
if (!x->x_focused)
{
clock_delay(x->x_clock_wait, 50);
my_numbox_set_change(x, 1);
post("...focusing for the first time");
clock_delay(x->x_clock_reset, 3000);
if (shift)
my_numbox_ftoa(x, 1);
else
x->x_buf[0] = 0;
x->x_focused = 2;
x->x_focused = 1;
x->x_oldval = x->x_val;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
else
{
my_numbox_set_change