Non-modal questdlg.m prompt

▼魔方 西西 提交于 2019-12-24 04:32:52

问题


My code makes a plot and then makes a prompt asking the user if he wants to make another plot with different parameters. The problem is, while questdlg.m is open, the user cannot look at details on the plot.

Here's the code :

while strcmp(Cont,'Yes') == 1

    %Some code modifying 'data'

    plot(1:X,data);
    Cont = questdlg('Would you like to plot another pixel?','','Yes','No','Yes');
    close all;

end

I've tried a few things. I tried to create another function called normalquestdlg.m, and I copy pasted the questdlg.m code into it, modifying line 401.

set(QuestFig,'WindowStyle','modal','Visible','on');

to

set(QuestFig,'Visible','on');

I tried different location for the normalquestdlg.m function. Putting it in my default Matlab folder for homemade functions gave me the following error :

Undefined function 'dialogCellstrHelper' for input arguments of type 'char'.

Error in **normalquestdlg** (line 74)
    Question = dialogCellstrHelper(Question);

Error in **Plot** (line 40)
    Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');

And putting it in the same folder as questdlg.m (C:\Program Files\MATLAB\R2014a\toolbox\matlab\uitools) gave me the following error :

Undefined function 'normalquestdlg' for input arguments of type 'char'.

Error in **Plot** (line 40)
    Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');

I even tried to put it as the first path to look for :

p = path
path('C:\Program Files\MATLAB\R2014a\toolbox\matlab\uitools', p)
Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');
path(p)

Needless to say, this didn't change a thing.

Anyone has any tips for me?


回答1:


No easy solutions were to be found. The easiest thing I could find was to download MFquestdlg.m (http://www.mathworks.com/matlabcentral/fileexchange/31044-specifying-questdlg-position/content/MFquestdlg.m) and modify line 384 of it this way :

set(QuestFig, 'WindowStyle', 'modal', 'Visible', 'on');

to

set(QuestFig, 'Visible', 'on');

since 'normal' is the default WindowStyle.

I prefered to do this than to modify basic Matlab functions. This could be enhanced even more (if someone had the need to do so) by adding an input in the function specifying the WindowStyle (either 'normal', 'modal' or 'docked'), and it would be quite easy, adding too a little fail-proof like line in this style :

if nargin < 8
    WinStyle = '%enter default mode'
end
if nargin == 8
    if strcmp(WinStyle,'normal') == 1 | strcmp(WinStyle, 'modal') == 1 | strcmp(WinStyle, 'docked') == 1
    else
        error('MATLAB:questdlg:IncorrectInput', 'The WindowStyle input parameter was incorrectly written')
    end
end


来源:https://stackoverflow.com/questions/23698453/non-modal-questdlg-m-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!