Skip to content

Commit 9c4a605

Browse files
committed
Fixed broken dragging for non-gui objects
1 parent e7d530b commit 9c4a605

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

pdlua.c

+24-26
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,17 @@ static void pdlua_reload(t_gobj* z)
729729

730730
static void pdlua_displace(t_gobj *z, t_glist *glist, int dx, int dy){
731731
t_pdlua *x = (t_pdlua *)z;
732-
x->pd.te_xpix += dx, x->pd.te_ypix += dy;
733-
dx *= glist_getzoom(glist), dy *= glist_getzoom(glist);
734732

735733
#if !PLUGDATA
736-
gfx_displace(z, glist, dx, dy);
734+
if(x->has_gui)
735+
{
736+
x->pd.te_xpix += dx, x->pd.te_ypix += dy;
737+
dx *= glist_getzoom(glist), dy *= glist_getzoom(glist);
738+
gfx_displace(z, glist, dx, dy);
739+
}
740+
else {
741+
text_widgetbehavior.w_displacefn(z, glist, dx, dy);
742+
}
737743
#endif
738744

739745
canvas_fixlinesfor(glist, (t_text*)x);
@@ -855,33 +861,25 @@ static void pdlua_menu_open(t_pdlua *o)
855861
PDLUA_DEBUG3("pdlua_menu_open: L is %p, name is %s stack top is %d", __L(), name, lua_gettop(__L()));
856862
if (name)
857863
{
858-
if (name[strlen(name)-1] == 'x')
864+
lua_getglobal(__L(), "pd");
865+
lua_getfield(__L(), -1, "_get_class");
866+
lua_pushlightuserdata(__L(), o);
867+
if (lua_pcall(__L(), 1, 1, 0))
859868
{
860-
/* pdluax is a class, the particular file should loadable by name alone, we hope */
861-
sprintf(pathname, "%s", name);
862-
lua_pop(__L(), 2); /* pop name and the global "pd" */
869+
pd_error(NULL, "lua: error in get_class:\n%s", lua_tostring(__L(), -1));
870+
lua_pop(__L(), 4); /* pop the error string, global "pd", name, global "pd"*/
871+
return;
863872
}
864-
else
865-
{
866-
lua_getglobal(__L(), "pd");
867-
lua_getfield(__L(), -1, "_get_class");
868-
lua_pushlightuserdata(__L(), o);
869-
if (lua_pcall(__L(), 1, 1, 0))
870-
{
871-
pd_error(NULL, "lua: error in get_class:\n%s", lua_tostring(__L(), -1));
872-
lua_pop(__L(), 4); /* pop the error string, global "pd", name, global "pd"*/
873-
return;
874-
}
875-
class = (t_class *)lua_touserdata(__L(), -1);
873+
class = (t_class *)lua_touserdata(__L(), -1);
876874
#if PLUGDATA
877-
if (!*class->c_externdir->s_name)
878-
path = plugdata_datadir;
879-
else
875+
if (!*class->c_externdir->s_name)
876+
path = plugdata_datadir;
877+
else
880878
#endif
881-
path = class->c_externdir->s_name;
882-
sprintf(pathname, "%s/%s", path, name);
883-
lua_pop(__L(), 4); /* pop class, global "pd", name, global "pd"*/
884-
}
879+
path = class->c_externdir->s_name;
880+
sprintf(pathname, "%s/%s", path, name);
881+
lua_pop(__L(), 4); /* pop class, global "pd", name, global "pd"*/
882+
885883
#if PD_MAJOR_VERSION==0 && PD_MINOR_VERSION<43
886884
post("Opening %s for editing", pathname);
887885
#else

0 commit comments

Comments
 (0)