Specify popup menu location on screen

조회 수: 9 (최근 30일)
Jason
Jason 2012년 1월 26일
OK, I know this is an easy one, but I can't seem to get the syntax right. I have a line of code in which a popup menu appears to ask for an input:
mnu = menu('Add an element not listed?', 'No', 'Yes');
As is, I can never predict where the popup menu will appear on the screen. How can I specify the menu location so that it always appears near the center of my screen?

채택된 답변

Jason
Jason 2012년 1월 26일
How about another way to accomplish the same thing, with some sort of uicontrol?
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 1월 27일
Sure. You can figure() to create a new figure at what-ever Position you want; set its window style to be 'modal'; and uicontrol() to your heart's content in the created figure.
If you
type menu.m
and study the code, you will see that the above is already what menu() does for the GUI case: it is just that menu has its own ideas about where the window should go rather than giving any kind of control to the caller.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 26일
You have no control over where menu() will place the popup. I just rechecked the source and there is no user control there.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by