Hyperlink embedded functions while script is running
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (1)
Vidip Jain
el 5 de Oct. de 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:
Ver también
Categorías
Más información sobre Dialog Boxes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!