From: Naresh Pai on
Is there a way to set uicontrol properties such that the text inside a pushbutton will wrap itself?

The alternative would be to use static text on the pushbutton.
From: Steven Lord on

"Naresh Pai" <npai(a)uark.edu> wrote in message
news:hhe44c$q55$1(a)fred.mathworks.com...
> Is there a way to set uicontrol properties such that the text inside a
> pushbutton will wrap itself?
> The alternative would be to use static text on the pushbutton.

No, but in the callback where you set the String property of the button you
can use TEXTWRAP:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/textwrap.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Naresh Pai on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hhsvrb$8fq$1(a)fred.mathworks.com>...
>
> "Naresh Pai" <npai(a)uark.edu> wrote in message
> news:hhe44c$q55$1(a)fred.mathworks.com...
> > Is there a way to set uicontrol properties such that the text inside a
> > pushbutton will wrap itself?
> > The alternative would be to use static text on the pushbutton.
>
> No, but in the callback where you set the String property of the button you
> can use TEXTWRAP:
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/textwrap.html
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>

I tried using textwrap as follows:

% Intialize a figure
hf = figure('Name','GUI');

% Define a uicontrol button
Btn_temp = uicontrol(...
'Parent',hf,...
'Units','normalized',...
'Position',[0.7,.15,.2,.1],...
'Style','pushbutton');

% Define a string for button
string = {'ABC DEF',...
'GHI JKL'};

% wrap string for uicontrol button
[outstring,newpos] = textwrap(Btn_temp,string);

% apply the string to the uicontrol button
set(Btn_temp,'String',outstring,'Position',newpos);

%The button string does not get the second line i.e. GHI JKL
From: Matt Fig on
From the documentation:

"For uicontrol objects that display only one line
of text (check box, push button, radio button, toggle button),
if the string value is specified as a cell array of strings or padded string
matrix, only the first string of a cell array or of a padded string matrix
is displayed; the rest are ignored. Vertical slash ('|') characters are not
interpreted as line breaks and instead show up in the text displayed in the
uicontrol."

You might be able to do something with the underlying JAVA. Putting a textbox over the top of the pushbutton introduces problems as well, because clicking on the string will not trigger the pushbutton's callback.

We will bring the JAVA man to this thread:

Calling Yair Altman!
From: Doug Schwarz on
Matt Fig wrote:
> From the documentation:
>
> "For uicontrol objects that display only one line
> of text (check box, push button, radio button, toggle button),
> if the string value is specified as a cell array of strings or padded
> string
> matrix, only the first string of a cell array or of a padded string matrix
> is displayed; the rest are ignored. Vertical slash ('|') characters are not
> interpreted as line breaks and instead show up in the text displayed in the
> uicontrol."
>
> You might be able to do something with the underlying JAVA. Putting a
> textbox over the top of the pushbutton introduces problems as well,
> because clicking on the string will not trigger the pushbutton's callback.
>
> We will bring the JAVA man to this thread:
>
> Calling Yair Altman!

Indeed, I would be interested in a Java way to do this, but in the
meantime my uibutton is available:

<http://www.mathworks.com/matlabcentral/fileexchange/10743-uibutton-gui-pushbuttons-with-better-labels>

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.