How can I use a drag and drop mechanism to activate a new figure?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!