我正在尝试在 SciLab 中设计一个 GUI,根据复选标记更新它的属性。例如:一个复选框可能会在回调期间启用和更改多个文本框的背景;或者一个按钮可能需要选择一定数量的复选框。
我的问题是,我似乎无法根据回调期间的复选框状态开发用于运行指令的流控制语句。我当前的 UIControl 元素如下所示:
handles.chkS11En=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.02140625,0.791119360625398,0.0803125,0.0369667],'Relief','flat','SliderStep',[0.01,0.1],'String','S11','Style','checkbox','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','chkS11En','Callback','chkS11En_callback(handles)')
当我选中复选框时运行的回调是这样的:
cS11En = findobj('tag', 'chkS11En'); // checkbox option
tS11MagUpperBound = findobj('tag', 'txtS11MagUpperBound'); //edit box that is controlled
mprintf("%d\n",cS11En.Value);
if cS11En.Value == [1] then
mprintf("Checked = on \n");
set(tS11MagUpperBound,'BackgroundColor',[1,1,1]);
set(tS11MagUpperBound,"Enable",'on');
set(cS11Save,"Enable",'on');
elseif cS11En.Value == [0] then
mprintf("Checked = off \n");
set(tS11MagUpperBound,'BackgroundColor',[0.8,0.8,0.8]);
set(tS11MagUpperBound,'Enable','off');
set(cS11Save,"Enable",'off');
end
这段代码的问题似乎是第二条路径(Value = 1)似乎永远不会运行,即使我不断切换复选框也是如此。我得到这样的输出:
0
Checked = off
0
Checked = off
0
Checked = off
0
Checked = off
为了重新加载检查元素,我做错了什么吗?我希望能够同时运行这两条路径,但是我似乎永远无法从复选框元素中获得 1 的值。有人对此有解决方案吗?谢谢!