Help - Nested uitogglebutton State Change Callback
显示 更早的评论
In matlab i have a nested uitogglebutton object. like this: fig > uipanel > uigridlayout > uibuttongroup > uitogglebutton. Because the toggle button is contained within uibuttongroup, uitogglebutton callabacks are not allowed. However, uibuttongroup SelectionChangedFcn fires callback if different button within buttongroup is selected and not toggle button state change. (Note: uicontrol with togglebutton not allowed when using uigridlayout). So, how do I detect a uitogglebutton state change and perform callback? Appreciate any help you can provide!
PseudoCode:
fig = figure(...)
panel = uipanel(fig, ...)
grid = uigridlayout(panel, ...)
btngrp = uibuttongroup(grid, ..., 'SelectionChangedFcn',selectionFcn)
tglbtn = uitogglebutton(btngrp, ...) %% callback not allowed on state change
function selectionFcn(src, event) %% Function not executed if togglebutton state change
selectedBtn - src.SelectedObject
if selectedBtn.Value == 1
DoSomething
else
DoSomethingElse
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!