Deselect uimenus after click in GUI
16次观看(最近30天)
显示older comments
Dear all,
I am facing a GUI issue. In the following example, if you click on a menu and slide to the other one, the second one is triggered. I don't want this behaviour. Could someone guide me toward a solution?
功能MWE(varargin)
handles.main = figure;
set(handles.main,'单位','pixels','位置',[300 300 210 50],...
'DockControls','Off','菜单栏','none','Toolbar','none');
handles.menu1 = uimenu(“父母”,hand.main,'Label','Menu1');
handles.menu2 = uimenu(“父母”,hand.main,'Label','Menu2');
handles.txt = uicontrol(handles.main,'Style','文本','单位','pixels',...
'String','','HorizontalAlignment','Center','位置',[5 5 200 40]);
set(handles.menu1,'打回来',{@fcn_txt,handles});
set(handles.menu2,'打回来',{@fcn_txt,handles});
end
功能fcn_txt(hObject,eventdata,handles)
set(handles.txt,'String',获取(hobject,'Label'));
end
我尝试了不同的解决方案,目前唯一起作金宝搏官方网站用的解决方案就是放一个侍应栏。我什至尝试使用Setarm Java方法。
Thank you for your help, Cédric
答案(2)
扬
on 28 Feb 2013
There might be an equivalent effect for UICONTROLs. Here even the focus remains at the UICONTROL, such that e.g. the KeyPress fcuntion of the figure is not triggered anymore. In this case a solution is:
set(ObjectH,'Enable','离开');
drawnow;
set(ObjectH,'Enable','on');
这比让java.robot单击任意立场更紧凑 - 在所有情况下,这是我避免的非常大胆的行动。
Jeffrey Girard
on 26 Feb 2015
编辑:Jeffrey Girard
on 26 Feb 2015
不幸的是,Jan的解决方案也对我不起作用。这些不是理想的解决方案,但我发现可以通金宝搏官方网站过以下方式避免这种行为。
- Adding a submenu with even one choice
- 用菜单回调生产某种形式的图形或对话框(“成功” MSGBOX)