GUI Question: Have a pop-up dialog which has license agreement? Accept/Decline pushbuttons.

Hi guys,
I want to have a pop-up dialogic box with 'accept' and 'decline' pushbuttons BEFORE the application is launched. If users hit 'decline', the application exits.
Is this possible?
Thank you

Answers (1)

Sure! You can, for instance, use QUESTDLG for this:
function Main
disp('Welcome to this function.') ;
ButtonName = questdlg('Do you accept agreement','License', ...
'Accept', 'Decline', 'Accept') ;
if ~isequal(ButtonName,'Accept')
disp('License not accepted. Program terminated.')
else
disp('Program continues.') ;
end

4 Comments

Thanks so much. I'm assuming that that function would go into the opening function of the program?
Lastly, what code can I use to terminate the program?
Thanks
If you are using a GUIDE GUI I would recommend creating a wrapper function with this in that launches the GUI afterwards only if the user selects 'Accept'.
Aborting a UI in the OpeningFcn tends to leave half-created ghost UIs hanging around that have not become visible but do still exist.
How could I create this wrapper function? I'm a little green to GUIDE...
Also, with 'questdlg' the user can just hit the cross in the top right of the dialog window to close it and still use the program?
thanks!
The wrapper function would just be like any other function.
Put Jos' code in it and then simply call your GUIDE GUI afterwards. You can call a GUI simply by its name (if it takes arguments pass them to it as a function, but I assume yours doesn't).
So in the else part of Jos' code you would launch your GUI as e.g.
MyGUI( );
If you GUI is in MyGUI.fig and MyGUI.m

Sign in to comment.

Categories

Find more on App Building in Help Center and File Exchange

Asked:

A
A
on 4 Mar 2016

Commented:

on 5 Mar 2016

Community Treasure Hunt

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

Start Hunting!