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

1 Ansicht (letzte 30 Tage)
Christian Idzik
Christian Idzik am 4 Aug. 2016
Bearbeitet: Christian Idzik am 4 Aug. 2016
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

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by