How to use the same callback function for 2 different codes

조회 수: 11 (최근 30일)
Kaavya N
Kaavya N 2021년 6월 22일
답변: Walter Roberson 2021년 6월 22일
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

답변 (1개)

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by