Scroll bar on App designer

조회 수: 94 (최근 30일)
Suyeon Byun
Suyeon Byun 2016년 8월 9일
답변: jonas 2020년 3월 2일
I have created GUI with app designer that comes with Matlab R2016a, but am having a struggle with adding a scroll bar on my GUI. Is there any way that I can integrate the scroll bar with GUI? Thank you, in advance.

답변 (2개)

Bekay.Kang
Bekay.Kang 2016년 8월 9일
Hope this would be helpful for you!
1) Create a uipanel() on your figure, the size of the viewing area.
2) Create a second uipanel() whose Parent is the first uipanel, and which is big enough to contain all of the data.
3) Draw your images, making sure that their Parent is the second uipanel.
4) Now configure the Callback on your scrollbar so that it changes the Position of the second uipanel. The edges of the first uipanel will "clip" the visibility of the second uipanel so that only the portion of the second uipanel that is behind the "window" that is the size of the first uipanel will be visible.
% code
figure(1)
panel1 = uipanel('Parent',1);
panel2 = uipanel('Parent',panel1);
set(panel1,'Position',[0 0 0.95 1]);
set(panel2,'Position',[0 -1 1 2]);
h = image;
set(gca,'Parent',panel2);
s = uicontrol('Style','Slider','Parent',1,...
'Units','normalized','Position',[0.95 0 0.05 1],...
'Value',1,'Callback',{@slider_callback1,panel2});
% code
function slider_callback1(src,eventdata,arg1)
val = get(src,'Value');
set(arg1,'Position',[0 -val 1 2])
  댓글 수: 1
craq
craq 2018년 7월 11일
The question specifically mentions the App Designer, and I think your suggestion is not compatible with it. I get the error:
Functionality not supported with figures created with the uifigure function.
For more information, see Graphics Support in App Designer.
A scroll bar would be a really nice feature for Mathworks to add to the App Designer in an upcoming release!

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


jonas
jonas 2020년 3월 2일
In 2019a you can check the "Scrollable" box under Interactivity. I've tested it for uipanels and the main uifigure.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by