How can I use a drag and drop mechanism to activate a new figure?
Afficher commentaires plus anciens
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
Réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!