Use enter button in inputdlg when file converted to exe

Hi! Is it possible for the inputdlg box to respond to the enter button instead of clicking at the ok button? I've got help to fix it when the program is executed in matlab, I'd like to be able to use the enter button when the file is converted to exe file. BR Johan

2 件のコメント

Titus Edelhofer
Titus Edelhofer 2011 年 6 月 27 日
I guess you tried to compile it? Usually the compiled version should behave like the "uncompiled" version ...
Titus
Johan
Johan 2011 年 6 月 28 日
I thought so too, unfortunately I was wrong:/

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2011 年 6 月 27 日

1 投票

Create a copy of "inputdlg.m" e.g. as "inputdlg2.m". Search for "uicontrol(EditHandle(1))". Add this line after the following END:
uicontrol(OKHandle);
Now the OK button is selected initially and hitting ENTER activates it. If the inputdlg2 files is created in a user folder (recommended!) insert the files MATLABROOT\toolbox\matlab\uitools\private\getnicedialoglocation.m and \private\setdefaultbutton.m also in inputdlg2.m.
Most likely a completely new created dialog file would be much smaller.

5 件のコメント

Johan
Johan 2011 年 6 月 28 日
Thanks, where should I save the folder and what should I name it? And just so I've understod, I should insert the code from getnicedialoglocation.m and setdefaultbutton.m in the inputdlg2 file?
BR
Johan
Johan
Johan 2011 年 6 月 28 日
I, tried your way and it kind of works, when I run the program it accepts enter as an "answer" but the result ends up being NaN instead of the requiered "1". Do you know why?
BR
Johan
Jan
Jan 2011 年 6 月 28 日
@Johan: I assume this depends on the initial values set by the input arguments. Please post the code you are calling INPUTDLG with.
Johan
Johan 2011 年 6 月 29 日
timelength=inputdlg('Hur länge vill du köra programmet? [min]')
timelength=str2double(timelength);
timelength=timelength*60./tid;
timelength=round(timelength);
Jan
Jan 2011 年 6 月 29 日
Please read "help inputdlg". If you call INPUTDLG without default answers, the empty string is replied and STR2DOUBLE converts it to NaN. Without defining a default answer, Matlab has no chance to know, that a "1" is required.
Use this to define a default value:
inputdlg('question', 'dialog name', 1, {'1'})

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDownloads についてさらに検索

製品

タグ

質問済み:

2011 年 6 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by