How to use the same callback function for 2 different codes
4 次查看(过去 30 天)
显示 更早的评论
Im using GUIDE and I have 2 panels , In one panel when I press a pushbutton the key value is displayed in the static text box , if I want the same key to be displayed in 2nd panel when I click the pushbutton in the first place what must be done. How to use the same callback function used in panel 1 for panel2. I hope this question makes sense
0 个评论
回答(1 个)
Walter Roberson
2021-6-22
In GUIDE, the easiest approach is to code the shared portion into a function, and call the function from both callbacks .
However... if you want to display the same key to the second panel, then that does not sound to me like using the same callback for two panels: that sounds to me as if you want a single callback to display into two different panels.
In GUIDE, you cannot (at least without difficulty) register the same push-button event to invoke two separate callbacks.
In GUIDE, when you talk about the "same callback function" that would mean shared code that is to apply in multiple circumstances. For example if you had a Radio Button Group then instead of coding a separate callback function for each different radio button, you might want to have the same function invoked no matter which of the radio buttons was pushed, with the code identifying which button it was called from and acting appropriately.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!