Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!sei!fs7.ece.cmu.edu!o.gp.cs.cmu.edu!netnews From: eht@cs.cmu.edu (Eric Thayer) Newsgroups: comp.sys.next Subject: Re: Button class bug ? Message-ID: <1991Feb27.134123.1082@cs.cmu.edu> Date: 27 Feb 91 13:41:23 GMT References: <1991Feb26.223500.20157@cs.mcgill.ca> Sender: netnews@cs.cmu.edu (USENET News Group Software) Organization: School of Computer Science, Carnegie Mellon Lines: 54 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 @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