I would like to know if it is possible to show a pushbutton string
with 2 lines of characters
Ej: _____
| READ |
| DATA |
________
THANKS IN ADVANCE
Unfortunately, I don't think there's any easy way to do this; the button
only accepts the first line of multi-line strings. But you can try a few
workarounds:
1) Use a program like Paint to create a bmp version of your text, and load
the file when you create the button. Set the 'cdata' property of the button
to the bmp. (Works well, but takes a bit of playing with.)
2) text overlay, with 'enable' set to 'off'
%This works well, but there is no way to trigger the callback of the
uicontrol text. Hence, you must set the enable to off, which makes the
button look like it is disabled. (Otherwise, you can click the button
outside of the text bounds, but a click within the text will be ignored.)
figure;
teststr = strvcat('Read','Data');
uicontrol('style','pushbutton','units','normalized','position',[0.4 0.4 0.2
0.2],'string','','tag','mybutton','callback','disp(''This is a test'')');
h=uicontrol('style','text','units','normalized','position',[0.45 0.45 0.1
0.1],'string',teststr,'enable','off','fontsize',12,'fontweight','b');
3) Adjacent buttons, each with 1 line of text
% May take some playing with to get the look you want, if indeed that is
even possible.
Sorry, no better suggestions at this time.
Cheers,
Brett
A work around using two uicontrols (tested in ML 6.5)
% == START CODE ==
cbstring = 'disp(''button pressed'')' ;
UN = {'units','normalized'} ; % for shortening lines
% a button
uicontrol('Style','Pushbutton',UN{:},'Position',[0.1 0.2 0.4
0.2],'callback',cbstring) ;
% a slightly smaller text box
uicontrol('Style','Text',UN{:},'Position',[0.11 0.21 0.38 0.18],...
'String',{'More lines','on a single','button'},...
'enable','inactive') ;
% mouse click is passed to
% underlying uicontrol or figure
% == END CODE ==
May be this can be of some use for you.
Jos
> 2) text overlay, with 'enable' set to 'off'
> %This works well, but there is no way to trigger the callback of the
> uicontrol text. Hence, you must set the enable to off, which makes the
> button look like it is disabled. (Otherwise, you can click the button
> outside of the text bounds, but a click within the text will be ignored.)
>
Hi Brett and Angel,
The third condition for enable will do the trick: inactive
Jos
Very nice, Jos. I wasn't aware that there WAS a third condition for enable.
Brett