Google Groepen ondersteunt geen nieuwe Usenet-berichten of -abonnementen meer. Historische content blijft zichtbaar.

how to show a pushbutton with 2 lines of string

200 weergaven
Naar het eerste ongelezen bericht

ANGEL

ongelezen,
15 jan 2004, 12:30:4315-01-2004
aan
hello every body

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

Brett Shoelson

ongelezen,
15 jan 2004, 14:26:0915-01-2004
aan

"ANGEL" <an-m...@terra.es> wrote in message
news:eece3...@webx.raydaftYaTP...

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


Jos

ongelezen,
16 jan 2004, 05:33:1316-01-2004
aan
ANGEL <an-m...@terra.es> wrote in news:eece3...@webx.raydaftYaTP:

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

Jos

ongelezen,
16 jan 2004, 05:44:3816-01-2004
aan
"Brett Shoelson" <shoe...@helix.nih.gov> wrote in
news:lPBNb.514$Er.3...@mencken.net.nih.gov:

> 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

Brett Shoelson

ongelezen,
16 jan 2004, 09:19:5216-01-2004
aan

> 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


0 nieuwe berichten