简体   繁体   English

如何在GUIDE中将一个功能分配给不同的UI控件?

[英]How to assign one function to different UI controls in GUIDE?

I have a set of push-buttons in a figure designed in GUIDE and I want to assign one single function as their callback functions. 在GUIDE中设计的图形中有一组按钮,我想将一个函数分配为其回调函数。 But there is no combo-box to choose my function from in the property inspector, and when I select all buttons and click Callback from View Callbacks menu it creates multiple callback functions. 但是在属性检查器中没有组合框可供选择,而当我选择所有按钮并从“ 查看回调”菜单中单击“ 回调”时 ,它将创建多个回调函数。 Same behavior when I hit the I-DON'T-KNOW-WHAT-TO-CALL button in the property inspector. 当我按下属性检查器中的“我不知道如何呼叫”按钮时,行为相同。

I can handle this with some coding in OpeningFcn like what described here or just with calling set(handle, 'method') , but I really prefer to do it in the designing environment. 我可以使用OpeningFcn一些编码(例如此处描述的编码)或仅调用set(handle, 'method')来处理此问题,但我真的更喜欢在设计环境中进行处理。

You can edit the Callback value within the Property Inspector. 您可以在属性检查器中编辑“ Callback值。 By default, it will be a custom callback for that uicontrol, but you can change it to be whatever you want. 默认情况下,它将是该uicontrol的自定义回调,但是您可以将其更改为所需的任何名称。

在此处输入图片说明

So for me, for two push buttons they are something like the following by default: 因此对我来说,对于两个按钮,默认情况下它们类似于以下内容:

@(hObject,eventdata)mygui('pushbutton2_Callback',hObject,eventdata,guidata(hObject))    
@(hObject,eventdata)mygui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))

Just copy the value of one into the other and they will have the same callback. 只需将一个的值复制到另一个中,它们将具有相同的回调。

Alternately, you can make them have a completely different callback by specifying your own value. 或者,您可以通过指定自己的值使它们具有完全不同的回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM