Can I set the Edit text slider position so that when the figure opens the slider is at the top of the scroll bar?

1 view (last 30 days)
I have created a multi-line Edit text component by executing the following code:
text = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'};
text = [ text text text ]; % Make it longer to ensure a scroll bar.
f1 = figure;
u1 = uicontrol(f1,'Style','edit','Units','normalized','position',[0 0 1 1],...
'String',text,'Max',1.001,'Min',0);
When this Edit text component is displayed, the slider position is always at the bottom of the scroll bar. I would like to set the slider position so that it is at the top of the scroll bar when the figure is displayed.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
The ability to set the slider position for a multi-line Edit box is not available in MATLAB. To work around this issue, use one of the following methods:
1. Edit your code as follows:
text = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'};
text = [ text text text ]; % make it longer to ensure a scroll bar
f1 = figure('Visible','off');
u1 = uicontrol(f1,'Style','edit','Units','normalized','Position',[0 0 1 1],...
'String',text,'Max',1.001,'Min',0);
drawnow
set(f1,'Visible','on')
The Essential Steps are:
a. Set the figure 'Visible' Property to off before adding the uicontrol
b. Set the figure 'Visible' Property to on after adding the uicontrol
c. R14SP2 - add a 'drawnow' before turning 'Visible' on (not necessary in R14SP3 and R2006a)
2. Use GUIDE to create the Edit text component. When the Edit text is created using GUIDE, the slider position is always set at the top of the scroll bar in R14SP3 and R2006a.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!