Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Is there clipping for uicontrol?

Subject: Is there clipping for uicontrol?

From: Nate

Date: 9 Jun, 2011 23:18:05

Message: 1 of 2

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

Subject: Is there clipping for uicontrol?

From: matt dash

Date: 9 Jun, 2011 23:41:05

Message: 2 of 2

"Nate" wrote in message <isrkbd$9m8$1@newscl01ah.mathworks.com>...
> 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

Can't be done as far as i know, but maybe yair altman knows something... he alludes to stacking uicontrols below other objects here http://undocumentedmatlab.com/todo/

One alternative is to draw something like a uicontrol using normal matlab plot objects.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us