|
What I am trying to do is to is to clip a uicontrol that moves beyond the border of a uipanel.
Let me know if you have any suggestions.
Thanks,
Nate
Here is some code of what I am doing:
function moving_panel_and_uicontrol
fig_h = figure;
main_panel_h = uipanel(fig_h,'position',[0.25 0.25 0.5 0.5]);
sub_panel_h = uipanel(main_panel_h,'position',[0.25 0.25 0.5 0.5]);
slider_h = uicontrol(fig_h,'style','slider','units','normalized', ...
'position',[0.8 0.25 0.1 0.5],'min',-1,'max',1,'value',0, ...
'sliderstep',[0.02 0.1],'callback',@slider_CB);
uicontrol(sub_panel_h,'style','edit','units','normalized', ...
'position',[0.1 0.1 0.8 0.1])
sub_panel_pos = get(sub_panel_h,'position');
function slider_CB(~,~)
slider_val = get(slider_h,'value');
set(sub_panel_h,'position',[sub_panel_pos(1) sub_panel_pos(2)+slider_val ...
sub_panel_pos(3) sub_panel_pos(4)])
end
end
|