Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
inputdlg

Subject: inputdlg

From: Simon Preston

Date: 16 Oct, 2008 06:34:01

Message: 1 of 4

Hi all,

When I use inputdlg the dialogue box is centred on the screen. Can somebody please tell me how I can specify the position?

Thanks,
Simon

Subject: inputdlg

From: Walter Roberson

Date: 16 Oct, 2008 06:57:36

Message: 2 of 4

Simon Preston wrote:

> When I use inputdlg the dialogue box is centred on the screen. Can somebody please tell
> me how I can specify the position?

There is no way to specify the position for inputdlg(), at least not in R2007a.

When I say "no way", I include that there are no obscure default properties
that are used but not mentioned in the help documentation: the *only* property
paid attention to in positioning the inputdlg() box is ScreenSize.

Therefore if you want the functionality of inputdlg but want a different
position, you will need to copy inputdlg.m under a different name, and modify
the copy to position the box the way you want.

Subject: inputdlg

From: Marcin

Date: 16 Oct, 2008 07:08:01

Message: 3 of 4

"Simon Preston" <preston.simon+mathsworks@gmail.com> wrote in message <gd6n8p$pho$1@fred.mathworks.com>...

> When I use inputdlg the dialogue box is centred on the screen. Can somebody please tell me how I can specify the position?

You can either modify inputdlg script or write a new one from scratch (which actually isn't that difficult). If you choose the first solution you should add another option specifying the position of the window to the Options structure and modify FigPos variable in lines:

FigPos=get(InputFig,'Position');

FigWidth=max(FigWidth,2*(BtnWidth+DefOffset)+DefOffset);
FigPos(1)=0;
FigPos(2)=0;
FigPos(3)=FigWidth;
FigPos(4)=FigHeight;


FigPos is a 1x4 matrix [left, bottom, width, height]. You are interested in left and bottom.
M.

Subject: inputdlg

From: Damien Gaillard

Date: 30 Mar, 2009 12:09:01

Message: 4 of 4

The following part of the code need to be replaced :

FigPos=get(InputFig,'Position');
FigWidth=max(FigWidth,2*(BtnWidth+DefOffset)+DefOffset);
FigPos(1)=0;
FigPos(2)=0;
FigPos(3)=FigWidth;
FigPos(4)=FigHeight;
set(InputFig,'Position',getnicedialoglocation(FigPos,get(InputFig,'Units')));

by this :

FigWidth = max(FigWidth,2*(BtnWidth+DefOffset)+DefOffset);
set(InputFig,'Position',[100 100 FigWidth FigHeight]);

where 100 100 are the coordinates of the upper left corner of the dialog box (they can be changed).

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us