GUI keyboard shortcut without using keypressfcn

Hello!
I want to create keyboard shortcuts for a GUI program, but it only appears inspector when I attempt to view callbacks, its .m file is not using callback handles to construct the GUI. The reason and solution HERE do not apply to my case. So the methods illustrated HERE are not working.
Is there a way I can create shortcuts without keypressfcn? Maybe by indexing the object tag?
Any help would be highly appreciated!

10 comentarios

Is this for guide or app designer?
Yukai Xu
Yukai Xu el 22 de Ag. de 2022
Editada: Yukai Xu el 22 de Ag. de 2022
Hi Walter! It's for guide, any idea how could I do this?
Is there a way I can create shortcuts without keypressfcn
Not that I can think of, except in the sense that you can use WindowKeyPressFcn (entire figure) rather than KeyPressFcn (specific axes or specific control)
Bruno Luong
Bruno Luong el 23 de Ag. de 2022
@Yukai Xu" but it only appears inspector when I attempt to view callbacks, its .m file is not using callback handles to construct the GUI."
I read it and must admit I don't not understand. I hope you know that you are free to change the callback function AND signature, include handles as input argument if you like.
Yukai Xu
Yukai Xu el 24 de Ag. de 2022
Hi @Walter Roberson,@Bruno Luong, thanks for your suggestions, but I really can't view WindowKeyPressFcn or other callbacks. Lots of errors turned out when I try to migrate the GUIDE fig to APP designer...
I can offer the .m and .fig program for if only you could take a look and help me : )
Again, thank you so much!
Bruno Luong
Bruno Luong el 24 de Ag. de 2022
I though you work with GUIDE.
Same here I never able to convert my GUI in AppDesigner. Too much features not convertible, too much speed issue, etc...
When you use Guide, you need to consider two different items.
The m file holds a couple of header functions, and then contains source code to implement the callbacks. The content of the callback implementation can be modified with any text editor, including outside of the control of Guide. Guide might be needed to connect the controls to the implementation when new functions are added.
The fig file is really a .mat file with a few special variables stored in it, including a figure() object. The graphics objects such as axes and uicontrol have various callback properties. When the callback is actie, what is really done is whatever is stored in the graphics object. Typically what is stored with the graphics object by Guide is a call that retrieves the gui handle object and calls into the function named by the m file name, passing in a character vector containing the name of the implementation function, and passing in the callback parameters, and the gui handles. But if you edit function names in the m file or especially if you rename the m file and fig file without going through Guide, then the m file and graphics object can get out of synchronization.
Occasionally, it can be necessary to examine the properties of the graphics object to see what callback properties are really stored there.
App Designer works a quite different way.
Yukai Xu
Yukai Xu el 6 de Sept. de 2022
Thank you so much! @Walter Roberson @Bruno Luong
I think now I know the reason why the .m file has no callback functions, the creator just chose 'Generate FIG file only' and maybe selected 'Command-Line Accessibility' to 'On', so that the mutiple figure axes could be more easily controled. So basicly I don't have the .m file generated automatically by GUIDE, the keypressfcn is not available here.
Any chance I can still make shortcuts without reconstructing the gui?
Bruno Luong
Bruno Luong el 6 de Sept. de 2022
Can you just load the fig file in GUIDE and uncheck the option 'Generate FIG file only'?
Yukai Xu
Yukai Xu el 6 de Sept. de 2022
Thank you for you advice! @Bruno Luong
Unfortunately, the buttons in my program work with original functions (in the mfile I described with no callbacks), so when MATLAB generates a new mfile for the GUI, I can actually find the callback functions and the buttons are assigned to these callbacks now, but apparently the GUI is controlled by blank functions now and my original mfile is not involving.
Seems I still have to reconstruct the GUI on the new mfile, thank you for all the help!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Desktop en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Ag. de 2022

Comentada:

el 6 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by