• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Disabled controls don't update their visual appearance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Disabled controls don't update their visual appearance


  • Subject: Disabled controls don't update their visual appearance
  • From: Christopher Campbell Jensen <email@hidden>
  • Date: Mon, 10 Aug 2009 18:04:36 +0200

Hi,

I am sure I am just missing a single line of code, but I can't understand the following behavior:
This code is where the issue occours:
- (void)refreshButtonsEnabledState
{
NSLog(@"%d", [[[tabView selectedTabViewItem] label] isEqualToString:@"Current/Custom"] && [movieFile.movieMetaData isCreated]);
[toggleWriteCheckMarksButton setEnabled:[[[tabView selectedTabViewItem] label] isEqualToString:@"Current/Custom"] && [movieFile.movieMetaData isCreated]];
[resetMetaDataButton setEnabled:[movieFile.movieMetaData isCreated]];
}


Now I am sure some of you might think this looks horrible, and it probably is. This is my first cocoa project, and I started out with the best intentions, but it has now unfortunately degraded to 'lets just get it to work' rather then following good design principles :(

Anyway, to help show what the problem is, I have made a screen recording showing the interface, the button in question and the console where you can observe the NSLog statement above being executed.
Screen recording: http://xrl.us/be9c6a


The button in question is the one labeled "Toggle" (the middle of the middle three), and really the one to the right of it labeled "Reset". The desired behavior is for these to be disabled as long as there is no files selected or loaded (entry in the right hand NSTableView), when a file is selected the movieFile variable is set to the file, and it's movieMetaData is created. When no file is selected, movieFile is set to nil. When the second tab is selected, "Toggle" should disable while "Reset" stays enabled. Once the file is removed (ie no files in the NSTableView) both buttons should disable, and it is this that fails. From the console, I can see that the method "refreshButtonsEnabledState" gets called and detects the right set of states (ie disable buttons; at least we know for sure that the "Toggle" one should disable) but this does not happen until I (I am guessing) force the window/view to refresh by selecting the other tab.

I have tried adding both:
[[[self window] view] setNeedsDisplay:YES];
or
[toggleWriteCheckMarksButton setNeedsDisplay:YES];

to the end of the "refreshButtonsEnabledState" method, but no dice.
I am sure I am doing all of this WAY too manual, and that there are all kinds of bindings I could use to accomplish this, but after struggling with bindings for a while now, I have opted to do more stuff manually. As this is a small bug, and I will probably be the only one to ever use this app, it's a small issue, but an annoyance even so.
I would love for someone to explain either what I am doing wrong, or what to add to fix the issue.


Thanks for your time,
Chris
_______________________________________________

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


  • Follow-Ups:
    • Re: Disabled controls don't update their visual appearance
      • From: Uli Kusterer <email@hidden>
  • Prev by Date: Re: How to find active user in the cocoa
  • Next by Date: Re: Trouble with event taps...
  • Previous by thread: Re: How to find active user in the cocoa
  • Next by thread: Re: Disabled controls don't update their visual appearance
  • Index(es):
    • Date
    • Thread