How can I use a drag and drop mechanism to activate a new figure?

1 回表示 (過去 30 日間)
Christian Idzik
Christian Idzik 2016 年 8 月 4 日
編集済み: Christian Idzik 2016 年 8 月 4 日
I made several GUI's in matlab's guide. One of them is my main menu(containts pushbuttons) in which you can choose a mode. I implemtent a drag and drop mechanism, so you can move the pushbuttons. This works quite well. Now I'm looking to a method to move one button into an area, so it activates the selected mode. That means that the current figure is closed and a new figure would appear. But I don't know how to manage this. Here you can see my drag and drop mechanism
function dragObject(hObject,eventdata)
handles = guidata(gcf);
handles.dragging = hObject;
handles.orPos = get(gcf,'CurrentPoint');
guidata(gcf,handles);
function dropObject(hObject,eventdata)
handles = guidata(gcf);
if ~isempty(handles.dragging)
newPos = get(gcf,'CurrentPoint');
posDiff = newPos - handles.orPos;
set(handles.dragging,'Position',get(handles.dragging,'Position') + [posDiff(1:2) 0 0]);
handles.dragging = [];
guidata(gcf,handles)
end
function moveObject(hObject,eventdata)
handles = guidata(gcf);
if ~isempty(handles.dragging)
newPos = get(gcf,'CurrentPoint');
X= newPos(1,1);
Y=newPos(1,2);
posDiff = newPos - handles.orPos;
handles.orPos = newPos;
set(handles.dragging,'Position',get(handles.dragging,'Position') + [posDiff(1:2) 0 0]);
guidata(gcf,handles)
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by