MATLAB の Figure に 1 つのボックスをドラッグ アンド ドロップするために必要な関数は既にあります。私が書いたコードは、図をいくつかのボックスで埋めます。別のループで、Figure をさらにボックス (文字列形式でさまざまな情報を保持) で埋めました。
これら 2 つのボックスのセットは、UserData に配置した番号によって関連付けられています (対応する番号。ボックスごとに、同じ UserData コンテンツを持つ別のボックスがあります)。同じ UserData を含む (したがって、それらを関連付ける) ボックスを見つけることで、最初のボックス セットのメンバーを、2 番目のボックス セットの対応するメンバーに対して同じ位置に再配置できるようにしたいと考えています。ドラッグしたばかりのボックス (uicontextmenu)。
function recallfcn(hObject,eventdata)
for ydx=1:2
diag_detail=get(gco,'UserData'); % This line should be in the drag fcn
diag_pos=get(gco,'Position'); % So should this one (for current objects)
xvar=diag_pos(1,1);
yvar=diag_pos(1,2);
detail=[diag_detail ydx];
set(findobj('UserData',detail),'Position',[xvar+(ydx-1.5) yvar+0.5 0.8 0.8]);
end
end
% ydx is only there to add another level of detail as I'm actually looking to move
% two boxes of the 'first kind', each of which have 2 numbers in user data, the first
% number being the same, and the second number distinguishing the first box from the
% second. The premise is the same.