【问题标题】:using a pushbutton's call back in an other callback in matlab使用按钮是matlab中另一个回调中的回调
【发布时间】:2013-07-02 10:54:43
【问题描述】:

我的 MATLAB GUI 中有两个按钮。我试图在 button1 的回调函数中识别一个按钮,并对按下哪个按钮做一些事情。我尝试使用按钮组并将所有按钮都放在该组中。单击任何这些按钮时,似乎没有代码。为什么?

这是我的代码:

function uibuttongroup1_SelectionChangeFcn(hObject,eventdata)  
    switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.  
    case 'notSimul'   
          disp('notSimul clicked')   
    case 'simul'  
        % Code for when radiobutton2 is selected.  
    case 'stopTest'  
        % Code for when togglebutton1 is selected.  
    case 'start'  
        % Code for when togglebutton2 is selected.  
    % Continue with more cases as necessary.  
    otherwise  
        % Code for when there is no match.  
end

【问题讨论】:

  • 您能否向我们展示将标签分配给项目并将回调添加到按钮的代码?您是否尝试过在 switch 语句中设置断点并查看 NewValue Tag 是什么?

标签: matlab matlab-guide


【解决方案1】:

如果我正确理解您的问题,即您在按钮组中放置了一个按钮,答案是它不起作用,因为按钮组应该只由切换按钮和单选按钮组成。正如您所描述的,当我尝试将按钮放入按钮组时,什么都不会发生。

【讨论】:

    猜你喜欢
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    • 2020-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多