diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 23bcf364fd2070f5110774ae059db13f22c6f696..ea9189f2e774546b00056fb527a3f45bf3bbfc27 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -6802,6 +6802,21 @@ function gui_canvas_get_overriding_scroll(cid) { exports.gui_canvas_get_overriding_scroll = gui_canvas_get_overriding_scroll; +/* ico@vt.edu 20200920: this last variant that executes immediately + is needed for g_text.c when one displaces a text object and it + immediately activates and it falls outside the visible canvas bounds + this can trigger the object to have its activated box at an incorrect + location due to asynchronous behavior of other getscroll calls. Having + it here as a separate call as it may prove useful later in other contexts. +*/ + +function gui_canvas_get_immediate_scroll(cid) { + //post("gui_canvas_get_immediate_scroll"); + do_getscroll(cid, 0); +} + +exports.gui_canvas_get_immediate_scroll = gui_canvas_get_immediate_scroll; + function do_optimalzoom(cid, hflag, vflag) { // determine an optimal zoom level that makes the entire patch fit within // the window diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 0c5a6284e747ce7ecaac09c23050917812bf4097..1da777dd92a0f981e7cb28a90b31dcc11e0ff111 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -1474,6 +1474,17 @@ void scrollbar_update(t_glist *glist) canvas_getscroll(canvas); } +/* ico@vt.edu 20200920: introduced for situation where getscroll +needs to occur before the next command, e.g. automate. */ +void scrollbar_synchronous_update(t_glist *glist) +{ + // glist_getcanvas is probably not needed but not before we make + // sure that there are unneded calls of this kind being made by + // non-toplevel objects... + gui_vmess("gui_canvas_get_immediate_scroll", + "x", glist_getcanvas(glist)); +} + void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) { wb->w_getrectfn = gr; diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index e978b67e974e925d8efea7dda327d9b6cddda74a..b7684019fe00dd5815513673e2b6da7a0500924e 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -290,6 +290,7 @@ EXTERN const char *iemgui_typeface(t_iemgui *x); EXTERN void iemgui_class_addmethods(t_class *c); EXTERN void scrollbar_update(t_glist *glist); +EXTERN void scrollbar_synchronous_update(t_glist *glist); EXTERN void iemgui_init(t_iemgui *x, t_floatarg f); EXTERN void iemgui_out_bang(t_iemgui *x, int o, int chk_putin); diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index a5321c1a1bd992a10f28adcf721c9d7f98c2d17c..bddca8c714b742e82441174e9193baa8d59b6926 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5216,12 +5216,12 @@ void canvas_mouseup(t_canvas *x, { /* after motion or resizing, if there's only one text item selected, activate the text */ + scrollbar_synchronous_update(x); if (x->gl_editor->e_selection && !(x->gl_editor->e_selection->sel_next)) { gobj_activate(x->gl_editor->e_selection->sel_what, x, 1); } - scrollbar_update(x); } else if (x->gl_editor->e_onmotion == MA_SCROLL) {