philwzo@cs.mcgill.ca (Philippe WIECZOREK) (02/27/91)
I wanted to change the name of a button. I used the
following code:
- changeTitle:sender
{
if ( condition )
[sender setTitle:"title1"];
else
[sender setTitle:"title2"];
return self;
}
I was forced to put a '[sender display]' just before the
'return self' in order to make the button redisplay properly. If
not, the two titles are one on the other. In that particular
case, the '1' of 'title1' will mix with the '2' of 'title2'.
Is this normal ? Or is it a bug of the button class ?
Of course, I am sure that the sender is actually a
button...
--
philwzo@cs.mcgill.ca Phil,
McGill University,
Montreal, Quebec,
CANADA.
--
eht@cs.cmu.edu (Eric Thayer) (02/27/91)
In article <1991Feb26.223500.20157@cs.mcgill.ca> philwzo@cs.mcgill.ca (Philippe WIECZOREK) writes: > > I wanted to change the name of a button. I used the > following code: > > - changeTitle:sender > { > if ( condition ) > [sender setTitle:"title1"]; > else > [sender setTitle:"title2"]; > > return self; > } > > I was forced to put a '[sender display]' just before the > 'return self' in order to make the button redisplay properly. If > not, the two titles are one on the other. In that particular > case, the '1' of 'title1' will mix with the '2' of 'title2'. I am not sure exactly what you are doing because the following code works for me (if you have internet access see pub/foo using anonymous ftp to moo.speech.cs.cmu.edu) /* Generated by Interface Builder */ #import "Controller.h" #import <appkit/Control.h> @implementation Controller - changeTitle:sender { static int i = 0; if (!i) { [sender setTitle:"foo"]; i = 1; } else { [sender setTitle:"bar"]; i = 0; } return self; } @end It alternates the title on the button between foo and bar without incident. Maybe you are using a different button flavor rather than the standard plain old button? ..eric
philwzo@cs.mcgill.ca (Philippe WIECZOREK) (02/27/91)
In article <1991Feb27.134123.1082@cs.cmu.edu>, eht@cs.cmu.edu (Eric Thayer) answered: >In article <1991Feb26.223500.20157@cs.mcgill.ca> philwzo@cs.mcgill.ca (Philippe >WIECZOREK) writes: >> >> I wanted to change the name of a button. I used the >> following code: >> >> [code deleted...] >> >> I was forced to put a '[sender display]' just before the >> 'return self' in order to make the button redisplay properly. If >> not, the two titles are one on the other. In that particular >> case, the '1' of 'title1' will mix with the '2' of 'title2'. > > >I am not sure exactly what you are doing because the following code works for >me (if you have internet access see pub/foo using anonymous ftp to >moo.speech.cs.cmu.edu) > > [code deleted...] > >It alternates the title on the button between foo and bar without incident. >Maybe you are using a different button flavor rather than the standard plain >old button? You are right, the button I have trouble with is not the standard plain button. It is a switch button. But what is the difference ? The switch button is a plain non-bordered button with icons (switch and swithH) on its side, isn't it ? >..eric > -- Phil, philwzo@cs.mcgill.ca --