Hyperlink embedded functions while script is running

1 次查看(过去 30 天)
I was hoping to create a simple MATLAB script that allows the user to click on text in the command window, rather than enter a number cooresponding with a menu item using input(). I am able to use hyperlinks in fprintf() statements to allow the user to run code, but only when MATLAB is idle. If I use input(), busy wait, or use pause(), the user cannot click the hyperlink and the system cannot unblock. Is there a way to run an idle task so the user can interact with the hyperlinks? What I would like to do is:
held = true;
fprintf('<a href="matlab:held = false;">Continue</a>');
while held
idle(); % allow user to click hyperlink
end
but no such idle() function exists as far as I am aware. Any thoughts or suggestions would be appreciated.

回答(1 个)

Vidip Jain
Vidip Jain 2023-10-5
I understand you want to create a simple MATLAB script that allows the user to click on text in the command window, rather than enter a number corresponding with a menu item using input().
One way is to use the ‘uiwait()’ and ‘uicontrol()’ function. The ‘uiwait()’ function blocks the execution of the MATLAB script until the user closes the specified dialog box. You can use this to create a simple dialog box with a hyperlink that the user can click to continue.
Another way to create your own idle function is to use the ‘drawnow()’ function. The ‘drawnow()’ function forces MATLAB to update all of the graphical objects in the current figure. You can use this to create a simple graphical object that the user can click to continue.
For further information, refer to the documentation link below:

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by