Deselect uimenus after click in GUI

16次观看(最近30天)
CédricDevivier
CédricDevivier on 27 Feb 2013
编辑: Jeffrey Girard on 26 Feb 2015
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
4条评论
CédricDevivier
CédricDevivier on 28 Feb 2013
I need the uimenu to lose the focus. It may be going somewhere else the figure for instance. I tried adding simply figure(gcf) but it did not work.

Sign in to comment.

答案(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单击任意立场更紧凑 - 在所有情况下,这是我避免的非常大胆的行动。
3 Comments
CédricDevivier
CédricDevivier on 28 Feb 2013
谢谢,我将其更改为单击同一图。

Sign in to comment.


Jeffrey Girard
Jeffrey Girard on 26 Feb 2015
编辑:Jeffrey Girard on 26 Feb 2015
不幸的是,Jan的解决方案也对我不起作用。这些不是理想的解决方案,但我发现可以通金宝搏官方网站过以下方式避免这种行为。
  1. Adding a submenu with even one choice
  2. 用菜单回调生产某种形式的图形或对话框(“成功” MSGBOX)

Categories

下载188bet金宝搏

Community Treasure Hunt

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

开始狩猎!