On 5 Apr 2017, at 10:45, J.E. Schotsman <jesc...@xs4all.nl> wrote:
> 
> On 03 Apr 2017, at 21:00, J.E. Schotsman wrote:
>> 
>> What is the Cocoa way of enabling/disabling a group of controls?
>> In Carbon I used to use a user pane for that.
>> I thought I would try an NSBox but then I realized it is not a control.
> 
> Nobody?
> I thought this would be a simple and solved problem.
> I tried subclassing MyEmbedder:NSControl and embedding in a custom view of 
> class MyEmbedder.
> Alas, setting the isEnabled property of the custom view has no effect on the 
> embedded controls.
> What am I missing?

I started writing a reply, then decided I was too busy and others would 
respond.  Since they haven’t, here’s my two cents:

1. AFAIK there isn’t a mechanism to disable all controls in a given subview.  
You could write code to do this easily enough, e.g.

  for (NSView *child in [groupView subviews]) {
    if ([child respondsToSelector:@selector(setEnabled:)])
      [child setEnabled:NO];
  }

  or you can bind all the Enable properties in the UI editor to the same value 
using bindings.

2. For some types of control, for instance toolbar buttons and menus, there’s a 
validation mechanism; you can just implement -validateUserInterfaceItem: and 
return YES or NO as appropriate.

3. It’s possible, at least in theory, to make your own controls conform to 
NSValidatedUserInterfaceItem, if that seems appropriate.  (This is kind of a 
gold-plated solution, and only applies in any case to controls with a target.)  
You’d probably want to start by reading about user interface validation:

<https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/UIValidation/UIValidation.html>

Kind regards,

Alastair.

--
http://alastairs-place.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to