Effacer les filtres
Effacer les filtres

Hyperlink embedded functions while script is running

1 vue (au cours des 30 derniers jours)
Robbie
Robbie le 9 Juin 2022
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.

Réponses (1)

Vidip Jain
Vidip Jain le 5 Oct 2023
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:

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by