Commit 3b43f5db authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Proper closure to the glist_grab saga in respect to iemgui numbox

* Reenabled the mouseup event that was mysteriously disabled for an unknown amount of time. This made it difficult to report to the object mouse release event after it has been dragged and the mouse ended-up being positioned outside object's bounds.

* This now allows for very nice control over objects that are being grabbed.

* Mouse release sets doubleclick flag to -1 to differentiate itself from the regular mouse movement which also reports mouse press as 0.

* Allowed for glist_grab to be exclusive in respect to key presses and settable as such via the glist_grab call. See iemgui numbox for benefits of this implementation, described below.

* Completely reworked numbox logic with additional variables designed to improve code readability and disambiguate the x->x_gui.x_changed and x->x_gui.x_change.

* Rotated the order of event propagation to have glist_grab 1st and event bound objects second (e.g. key/keyname etc.). THIS IMPLEMENTATION SHOULD BE HEAVILY SCRUTINIZED TO MAKE SURE THERE ARE NO ADVERSE EFFECTS. Given the rapid release cycle I suggest adding it to the next release and then observing user feedback.

* The numbox now offers the following behavior:

1) click and drag and release (with or without shift which can be pressed at any time to toggle between fine +-0.01 and +-1 increments) which immediately changes the number value and outputs it. This kind of grab does not do exclusive keyboard grab and therefore allows keyboard to still propagate to other bound events.

2) click and immediately release enters the exclusive keyboard mode and makes the '>' appear to make the user aware of this. Here you can use arrows up/down with and without shift, press allowed keyboard keys (numbers, enter, delete, etc.) and edit the value accordingly. Pressing arrows always changes the last digit of the currently truncated number. Pressing enter commits the value and retains the focus for another 3 seconds unless user presses Esc or clicks outside the number box. If all the digits are erased the number implicity assumes 0.

3) clicking and immediately releasing without shift pressed to activate exclusive keyboard mode activates legacy/default behavior where entered text overwrites the existing (the cursor starts at the beginning and initially only has '>'). Doing the same with shift key puts the numbox in the append mode where one can continue adding to the previously committed number. This is even true if the displayed number is simply '+' or '-' due to it exceeding the number box width (not including decimals).

4) Values whenever committed are clipped to the object's min and max and reflected as such in the number object. If the object remains activated, the number is not clipped if it exceeds the object's length, but shows only last n visible digits. Upon removing focus (activation), it redraws from the beginning (if number of digits exceeds the width but does not exceed the min/max thresholds. Re-activating the object redraws it with the last digits visible.

* All glist_grab instances in externals should be taken care of and are, by default, not exclusive.

* Still TODO: checking if vanilla numbox is working ok. The rest of the objects shoould be unaffected.
parent a20427d0
......@@ -183,7 +183,6 @@ typedef struct _my_numbox
t_iemgui x_gui;
t_clock *x_clock_reset;
double x_val;
double x_oldval;
double x_min;
double x_max;
double x_k;
......@@ -206,6 +205,10 @@ typedef struct _my_numbox
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; /* used to keep track if the number box was dragged, so that
even if we arrive back at the previous number, it does not
activate with exclusive keyboard focus. This is why old_val
comparison is not a good one */
} 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 > 0 && x->gl_editor->e_grab && x->gl_editor->e_keyfn)
if (doit && 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 > 0 && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
if (doit && !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 > 0)
if (doit)
{
//fprintf(stderr,"doit %d\n", x->gl_editor->e_onmotion);
if (x->gl_editor->e_onmotion == MA_MOVE)
......@@ -3728,7 +3728,6 @@ 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);
......@@ -3812,7 +3811,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 > 0) {
if (!ctrl_runmode_warned && ctrlmod && !rightclick && doit) {
post("\nwarning: The hotkey for temporary run mode has changed. "
"Please press Alt instead of Ctrl to enable it.\n");
ctrl_runmode_warned = 1;
......@@ -3827,7 +3826,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 > 0)
if (doit)
{
if (glist_isselected(x, y))
glist_deselect(x, y);
......@@ -3854,7 +3853,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
if (in_text_resizing_hotspot)
{
// ...and we are clicking...
if (doit > 0)
if (doit)
{
// ...select the object
if (!glist_isselected(x, y) ||
......@@ -3942,7 +3941,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
//post("Outlet found...");
//...and we are clicking on it
if (doit > 0)
if (doit)
{
//fprintf(stderr,"start connection\n");
int issignal = obj_issignaloutlet(ob, closest);
......@@ -4023,7 +4022,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 > 0)
if (doit)
goto nooutletafterall;
}
}
......@@ -4077,12 +4076,12 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
{
canvas_check_nlet_highlights(x);
}
if (doit > 0)
if (doit)
goto nooutletafterall;
}
}
/* not in an outlet; select and move */
else if (doit > 0)
else if (doit)
{
t_rtext *rt;
/* check if the box is being text edited */
......@@ -4155,7 +4154,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
}
else if (in_text_resizing_hotspot) /* red gop rectangle */
{
if (doit > 0)
if (doit)
{
x->gl_editor->e_onmotion = MA_RESIZE;
x->gl_editor->e_xwas = x1;
......@@ -4218,7 +4217,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 > 0)
if (doit)
{
glist_selectline(glist2, oc,
canvas_getindex(glist2, &t.tr_ob->ob_g), t.tr_outno,
......@@ -4284,7 +4283,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 > 0)
if (doit)
{
if (!shiftmod &&
(x->gl_editor->e_selection || x->gl_editor->e_selectedline))
......@@ -5291,7 +5290,6 @@ 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
{
......@@ -5307,7 +5305,6 @@ 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);
......@@ -5364,23 +5361,24 @@ 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. 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)
{
// here we borrow the double-click flag and make it -1 which signifies
// mouse up since otherwise doit (the last argument) value of 0 is
// shared between mouse up and mouse motion, making this unclear
int clickreturned = gobj_click(
x->gl_editor->e_grab, x, xpos, ypos, 0, 0, 0, -1);
post("clickreturned=%d", clickreturned);
x->gl_editor->e_grab, x, xpos, ypos, glob_shift, glob_alt, -1, 0);
x->gl_editor->e_onmotion = MA_NONE;
}
canvas_doclick(x, xpos, ypos, 0,
(glob_shift + glob_ctrl*2 + glob_alt*4), -1);
(glob_shift + glob_ctrl*2 + glob_alt*4), 0);
//}
// now dispatch to any click listeners
canvas_dispatch_mouseclick(0., xpos, ypos, which);
......@@ -5635,7 +5633,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
// now broadcast key press to key et al. objects
// 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));
//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)
......@@ -5791,6 +5789,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
//fprintf(stderr," %d %d %d %s %d %d\n",
// glob_shift, glob_ctrl, glob_alt, gotkeysym->s_name, keynum, down);
//canvas_motion(x, canvas_last_glist_x, canvas_last_glist_y, canvas_last_glist_mod);
// call canvas_motion, so that we can update modifiers...
pd_vmess(&x->gl_pd, gensym("motion"), "fff",
(double)canvas_last_glist_x,
(double)canvas_last_glist_y,
......@@ -5815,7 +5814,6 @@ 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);
......
......@@ -36,12 +36,9 @@ static void my_numbox_tick_reset(t_my_numbox *x)
{
//post("tick_reset\n");
my_numbox_remove_grab(x);
if(x->x_gui.x_changed && x->x_gui.x_glist)
{
//post(" success\n");
if(x->x_gui.x_changed)
my_numbox_ftoa(x, 0);
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
// change the grab state depending on the current level of focus
......@@ -59,11 +56,13 @@ void my_numbox_clip(t_my_numbox *x)
if(x->x_val < x->x_min)
{
x->x_val = x->x_min;
x->x_gui.x_changed = 2;
}
if(x->x_val > x->x_max)
{
x->x_val = x->x_max;
x->x_gui.x_changed = 2;
}
}
......@@ -83,6 +82,9 @@ int my_numbox_calc_fontwidth(t_my_numbox *x)
x->x_num_fontsize);
}
// we enable append flag when we want the value to be still displayed as-is
// without it being converted to + or - because it falls outside the numbox size
// boundaries
static void my_numbox_ftoa(t_my_numbox *x, int append)
{
double f=x->x_val;
......@@ -138,14 +140,13 @@ static void my_numbox_ftoa(t_my_numbox *x, int append)
x->x_buf[x->x_gui.x_w] = 0;
}
}
//post("ftoa buf=%s", x->x_buf);
}
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);
//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
......@@ -156,15 +157,20 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
// if we are activated (focused)
if(x->x_focused && x->x_buf[0])
{
//post("draw_update 1 : focused=%d", x->x_focused);
int cursor_added = 0;
//post("...draw_update 1 : focused=%d <%s> buflen=%d",
// x->x_focused, x->x_buf, strlen(x->x_buf));
char *cp=x->x_buf;
int sl = strlen(x->x_buf);
// if we have been typing (focused == 2)
// if we have been typing (focused == 3)
if (x->x_focused == 3)
{
x->x_buf[sl] = '>';
x->x_buf[sl+1] = 0;
} else if (x->x_focused == 2) {
sl++;
cursor_added = 1;
}
else if (x->x_focused == 2) {
// 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
......@@ -179,25 +185,36 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
}
else
{
// otherwise, display it as-is without the '>'
// otherwise, display it as-is
x->x_buf[sl] = 0;
sl--;
}
}
// now update the object, retaining its activated state (last argument)
// lastly, in case the number is longer than the number width, update the text offset
//post("...offset=%d width=%d", sl, x->x_gui.x_w);
if(sl >= x->x_gui.x_w)
cp += sl - x->x_gui.x_w + 1;
{
cp += sl - x->x_gui.x_w;
//post("......new offset=%d", cp);
}
// send content to the front-end activated (last argument)
gui_vmess("gui_text_set_mynumbox", "xxsi",
glist_getcanvas(glist),
x,
cp,
1);
// now get rid of the cursor in the x->x_buf after it has been passed to the GUI
// to prevent the corruption of future keyboard input updates (e.g. without this
// pressing 1 and then 2 will otherwise generate "1>2>")
if (cursor_added)
{
x->x_buf[sl-1] = 0;
}
}
else
{
// 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);
//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)
{
......@@ -618,15 +635,15 @@ 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)
{
post("my_numbox_motion");
if (x->x_focused == 1)
if (x->x_focused == 1 && dy)
{
double k2=1.0;
x->x_gui.x_changed = 1;
x->x_dragged = 1;
// 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;
......@@ -635,13 +652,10 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg 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);
}
my_numbox_ftoa(x, 1);
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);
}
......@@ -652,10 +666,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)
{
post("my_numbox_click: is this even being used at all other than below?");
//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, 0, my_numbox_list,
(t_floatarg)xpix, (t_floatarg)ypix, 0);
xpos, ypos, 0);
}
// this one gets called on both mouse down and mouse up (doit reports the mouse state)
......@@ -663,11 +677,10 @@ 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 == 1)
if (doit)
{
post("...my_numbox_newclick calling my_numbox_click...");
//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);
......@@ -684,9 +697,10 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
// if we are clicking on the object for the first time and are
// about to focus onto it
// LATER: reconcile the following if/else statements
if (!x->x_focused)
{
post("...focusing for the first time");
//post("|...focusing for the first time");
clock_delay(x->x_clock_reset, 3000);
if (shift)
......@@ -694,13 +708,13 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
else
x->x_buf[0] = 0;
x->x_focused = 1;
x->x_oldval = x->x_val;
x->x_dragged = 0;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
else
{
post("...refocusing");
//post("|...refocusing");
// we have already been mouse focused only, and are clicking
// on the object again
//
......@@ -717,20 +731,24 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
else
x->x_buf[0] = 0;
x->x_focused = 1;
x->x_oldval = x->x_val;
x->x_dragged = 0;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
}
else if (doit == -1)
// we have to check if we are focused and that dbl (a.k.a. double-click) is -1
// as that suggests a genuine mouseup among all the mouse motion messages
// in g_editor.c that also have doit = 0
else if (x->x_focused && dbl == -1)
{
// here we check if the user has immediately let go of the mouse button
// which should put us in the exclusive text activated mode
// which should put us in the exclusive text activated mode.
// we ignore focused = 2 state
if (x->x_focused == 1)
{
post("...letting go focused=1");
if (x->x_oldval == x->x_val)
//post("|...letting go focused=1");
if (!x->x_dragged)
{
post("...entering exclusive");
//post("|...entering exclusive");
x->x_focused = 3;
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,
......@@ -739,8 +757,8 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
}
else
{
x->x_oldval = x->x_val; // do we need this?
post("...dragging complete, deactivating");
x->x_dragged = 0;
//post("|...dragging complete, deactivating");
// we have dragged the mouse, changed the value,
// and should immediately release focus
clock_unset(x->x_clock_reset);
......@@ -850,7 +868,7 @@ static void my_numbox_loadbang(t_my_numbox *x, t_floatarg action)
static void my_numbox_key(void *z, t_floatarg fkey)
{
t_my_numbox *x = z;
post("numbox_key %f <%s>", fkey, x->x_buf);
//post("numbox_key %f <%s>", fkey, x->x_buf);
if (fkey != 0)
{
x->x_focused = 3;
......@@ -874,8 +892,8 @@ static void my_numbox_key(void *z, t_floatarg fkey)
// and therefore loses focus
if (c == 0)
{
x->x_oldval = x->x_val; // do we need this?
post("...either clicking outside the number or dragging complete, deactivating");
x->x_dragged = 0; // do we need this?
//post("...clicking outside the number, deactivating");
my_numbox_remove_grab(x);
clock_unset(x->x_clock_reset);
x->x_gui.x_changed = 1;
......@@ -900,10 +918,14 @@ static void my_numbox_key(void *z, t_floatarg fkey)
// and the numbox is still focused, and we got clipped
// down to 0, make sure that our first digit goes to the
// first, not second place
strcpy(x->x_buf, buf);
strcpy(x->x_buf, buf);
//post("->STRCPY <%s>", x->x_buf);
}
else
{
strcat(x->x_buf, buf);
//post("->STRCAT <%s>", x->x_buf);
}
x->x_gui.x_changed = 1;
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}
......@@ -926,16 +948,9 @@ static void my_numbox_key(void *z, t_floatarg fkey)
x->x_val = atof(x->x_buf);
//x->x_buf[0] = 0;
clock_unset(x->x_clock_reset);
double oldval = x->x_val;
x->x_gui.x_changed = 1;
my_numbox_clip(x);
x->x_focused = 2;
if (oldval != x->x_val)
{
// we have changed the value and it was clipped
x->x_gui.x_changed = 2;
}
else
x->x_gui.x_changed = 1;
my_numbox_bang(x);
if (x->x_shiftclick == 0)
{
......@@ -975,8 +990,8 @@ static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
}
else if (ac == 2 && IS_A_FLOAT(av,0) && IS_A_SYMBOL(av,1))
{
if (!x->x_gui.x_changed)
my_numbox_ftoa(x, 1);
//if (!x->x_gui.x_changed)
// my_numbox_ftoa(x, 1);
//post("got keyname %s %d while grabbed\n",
// av[1].a_w.w_symbol->s_name, av[0].a_w.w_float);
// we allow shift to propagate in both focused modes 1 and 2
......@@ -988,11 +1003,14 @@ static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
}
if (x->x_focused > 1 && av[0].a_w.w_float == 1)
{
if (!strcmp("Up", av[1].a_w.w_symbol->s_name))
{
//fprintf(stderr,"...Up\n");
if(x->x_buf[0] == 0 || x->x_buf[0] == '>')
sprintf(x->x_buf, "%g", 1);
{
sprintf(x->x_buf, "%g", 1.0);
}
else
sprintf(x->x_buf, "%g", atof(x->x_buf) + 1);
my_numbox_key((void *)x, -1);
......@@ -1010,7 +1028,7 @@ static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
{
//fprintf(stderr,"...Down\n");
if(x->x_buf[0] == 0 || x->x_buf[0] == '>')
sprintf(x->x_buf, "%g", -1);
sprintf(x->x_buf, "%g", -1.0);
else
sprintf(x->x_buf, "%g", atof(x->x_buf) - 1);
my_numbox_key((void *)x, -1);
......@@ -1109,7 +1127,7 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
x->x_focused = 0;
x->x_yresize_x = 0;
x->x_shiftclick = 0;
x->x_oldval = 0;
x->x_dragged = 0;
return (x);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment