NSButton alternate image problem - not redrawing
NSButton alternate image problem - not redrawing
- Subject: NSButton alternate image problem - not redrawing
- From: P Teeson <email@hidden>
- Date: Wed, 16 Jul 2008 12:28:32 -0400
Mac OS X Tiger 10.4.11, Xcode 2.5, G4 867mhz
I am making a Cocoa Application kids game using NSButtons.
They are of behaviour Toggle and of type Square Button and the icon
position is centred (i.e. no title) and each button has a unique tag
and is enabled.
The icon images are in the nib file and consist of
(a) a coloured blank square and
(b) a set of coloured squares with large letters in the centre.
In the nib all buttons have the blank icon image as both image and
alternate image. Connections are made in IB from each button to the
Controller IBAction method. Likewise connections are made from
the Controller IBOutlets to the respective buttons.
When the game begins I successfully retrieve all the icon images from
the bundle
and keep them as instance variables in my Controller.
(e.g. IBOutlet NSButton * cell0; IBOutlet NSButton *cell1; etc)
The game is played by clicking on a button and a message is sent to
an IBAction method
in the Controller. It replaces the alternate image with one of the
(b) icons and disables that button.
......
[sender setAlternateImage:theXiconImage];
[sender setEnabled:NO];
......
This all works exactly and desired.
There is another NSButton to trigger a New Game and it sends a
message to an IBAction method
in the Controller that re-initialises the buttons as follows:
......
[cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet
[cell0 setEnabled:YES];
[cell1 setAlternateImage:theBlankImage];
[cell1 setEnabled:YES];
[cell2 setAlternateImage:theBlankImage];
[cell2 setEnabled:YES];
etc....
......
(Of course the Model is also reinitialised)
My Problem is this
The View gets redrawn OK.
But now when clicking on a button there is no guarantee that the
alternate images will appear.
Sometimes they do; sometimes they don't - just displaying the blank
icon.
And yet the same action method is being called as in the first play
of the game.
Why do you think this is not redrawing correctly after the
reinitialisation?
TIA for your suggestions.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden