Why does 'Position' property not change the width of uicontrol slider?

조회 수: 8 (최근 30일)
Hello, I am trying to change the width of a slider in a simple way:
f = figure;
s = uicontrol('Parent',f,'Style','slider','Position',[100,100,200,10]);
s.Position(4) = 100;
s.Position(4) = 0;
But the slider only changes its position and doesn't change the size. Even if I set the width to zero. While Position(1:3) works properly. What am I doing wrong? Matlab R2016a. Mac OS 10.11.6. Thank you in advance.
  댓글 수: 2
Robert
Robert 2016년 10월 5일
For what it's worth, this works fine (changes the height) in R2016a on Windows 10.
Do you get the same behavior with the following?
set(s,'Position',[100,100,200,100])
Pavel
Pavel 2016년 10월 5일
Dear Robert, thank you for the prompt reply. Yes, I get the same behaviour as you can see from the attached screen shots.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 5일
On my OS-X (Yosemite) system, R2016a or R2016b, changing the 4th value has the visual appearance of changing the height at which the slider is drawn.
It looks to me as if the explanation is that OS-X is always rendering the slider itself as the same height, and what you adjust by changing the 4th parameter is the size of the box it is rendered in.
  댓글 수: 2
Pavel
Pavel 2016년 10월 5일
편집: Pavel 2016년 10월 5일
Thank you for the reply! Yes, it looks like it's particular behaviour of the OS-X. OK, luckily, it isn't a big problem for me)
Walter Roberson
Walter Roberson 2016년 10월 6일
I confirm the same thing happens in Sierra.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matthew Eicholtz
Matthew Eicholtz 2016년 10월 5일
The width of the slider is the third element of the Position vector, not the fourth, which is height. Try something like:
s.Position(3) = 100;
to see if the width changes.
  댓글 수: 1
Pavel
Pavel 2016년 10월 5일
It doesn't matter, I mean the smallest side of the object for the 'width'. The problem is that I can't change the smallest side.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by