在另一个按钮回调中调用一个按钮回调

发布于 2025-01-05 07:55:26 字数 501 浏览 0 评论 0原文

我正在尝试在另一个按钮回调中进行按钮回调,但我遇到了问题:

这就是我想要做的:

C_N_Callback(hObject,eventdata, handles)

   RN_Callback(handles, [], []);

我尝试了此操作但给出了此错误:

尝试引用非结构数组的字段。

第一步,在 RN_Callback 中执行 getappdata

我也尝试过这个:

C_N_Callback(hObject,eventdata, handles)

   RN_Callback(hObject,eventdata, handles);

这没有给出错误,但是当我运行 GUI 时,它会继续执行 RN_Callback 中的过程(我猜刷新时)。

I am trying to pushbutton callback in an another pushbutton callback, but I am having problems:

Here is what i am trying to do:

C_N_Callback(hObject,eventdata, handles)

   RN_Callback(handles, [], []);

I tried this but gave this error:

Attempt to reference field of non-structure array.

Inside RN_Callback at first step where it is doing getappdata.

I also tried this:

C_N_Callback(hObject,eventdata, handles)

   RN_Callback(hObject,eventdata, handles);

This did not give error but when i run the GUI it keeps doing the procedure in RN_Callback (i guess on refresh).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱桃奶球 2025-01-12 07:55:26

也许RN_Callback正在使用对hObject的引用。只是提醒您,hObject 是调用回调的对象。因此,在您的情况下,它将是 C_N ,它将传递给 RN_Callback 而不是 RN

在这种情况下,代码将是错误的,因为它需要一种类型的 GUI 对象,但得到的是另一种类型。例如:

function RN_Callback(hObject,eventdata, handles)
     set(hObject,'String','This is me!');
end    

function C_N_Callback(hObject,eventdata, handles)
     RN_Callback(hObject,eventdata, handles);
end

单击 RN 将更改其字符串。但点击 C_N 将更改 C_N,而不是您可能期望的 RN

Perhaps RN_Callback is using the reference to hObject. Just to remind you, hObject is the object on which the callback is being called. So in your case, it will be C_N , which will be passed to RN_Callback instead of RN.

In that case, the code will be wrong, because it expects a GUI object of one type, but gets another. For example:

function RN_Callback(hObject,eventdata, handles)
     set(hObject,'String','This is me!');
end    

function C_N_Callback(hObject,eventdata, handles)
     RN_Callback(hObject,eventdata, handles);
end

Clicking on on RN will change its string. But clicking on C_N will change C_N, instead of RN as you might have expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文