Switch value in uifigure is inverted

1 次查看(过去 30 天)
Hi,
The following function taken from https://www.mathworks.com/help/matlab/ref/uiswitch.html doesn't behave as expected in Matlab 2020a
"Switch That Changes Lamp Color"
function lampswitch
fig = uifigure('Position',[100 100 370 280]);
lmp = uilamp(fig,...
'Position',[165 75 20 20],...
'Color','green');
sw = uiswitch(fig,'toggle',...
'Items',{'Go','Stop'},...
'Position',[165 160 20 45],...
'ValueChangedFcn',@switchMoved);
% ValueChangedFcn callback
function switchMoved(src,event)
switch src.Value
case 'Go'
lmp.Color = 'green';
case 'Stop'
lmp.Color = 'red';
end
end
end
The switch value is somehow inverted! Lamp is red when switch is on "Go"(see video here https://www.dropbox.com/s/ms4lrk0x4q88sle/VID_20200704_123830.mp4?dl=0). Sorry for the low quality.
  6 个评论
Roberto De
Roberto De 2020-7-6
I did further testing: only the uilamps object are affected, other code inside the switch case statements work fine.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by