在我的 GUIDE 生成的 gui 中,我有一个轴对象,imshow()
当 gui 初始化时,我将位图放入其中。我有一个 WindowButtonMotion 回调定义为:
function theGui_WindowButtonMotionFcn(hObject, eventdata, handles)
% handles.mode_manager is initialized in the gui startup code
if (isempty(handles.mode_manager.CurrentMode))
obj_han=overobj('axes');
if ~isempty(obj_han)
set(handles.theGui, 'Pointer','cross');
else
set(handles.theGui, 'Pointer','arrow');
end
end
end
我在工具栏上的打开文件按钮上有一个回调:
function openFile_ClickedCallback(hObject, eventdata, handles)
% handles.image_handle received the handle from the imshow that
% opened the initial image
tmp_handle = handles.image_handle;
[name, path] = uigetfile({'*.bmp'; '*.jpg'});
if (path == 0)
return
else
filename = strcat(path, name);
end
% read the image into the axes panel
hold on
handles.image_handle = imshow(filename);
set(handles.image_handle, 'ButtonDownFcn', @imageMouseDown);
handles.mode_manager = uigetmodemanager();
delete(tmp_handle);
guidata(hObject, handles);
end
新图像显示在 gui 的坐标区对象中后,指针不再变为坐标区对象上的十字。问题与新显示的图像有关,因为如果我注释掉实际显示新图像的代码部分,则在调用 openFile 回调后指针显示为十字。