Re: disable group of controls

2017-04-05 Thread J.E. Schotsman

> On 05 Apr 2017, at 15:26, Keary Suska  wrote:
> 
> How so? You can have multiple enabled bindings on a control, and if any 
> return NO the control stays disabled.

Aha, that solves the problem for me.
I still think the Carbon user pane provided a simpler solution.

> If you aren’t using bindings for the “latent” state, the responsible 
> controller can observe the group disable property and adjust accordingly.

I was trying something along these lines but then I got into a flipped drawing 
conundrum.

Jan E.

___

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

Re: disable group of controls

2017-04-05 Thread Alastair Houghton
On 5 Apr 2017, at 12:05, J.E. Schotsman  wrote:
> 
>> On 05 Apr 2017, at 11:48, Jack Carbaugh  wrote:
>> 
>> Get a list of the controls then loop through it, setting each enabled 
>> property to false. The container holding them will hold a reference to them
> 
> That way you lose the latent enabled state.
> When the embedder is set to disabled some of the sub controls may already be 
> disabled.

As a general principle, the UI shouldn’t be being used to store things; it 
should instead reflect the internal state of your program.  Put another way, 
*your code* should keep track of which controls are supposed to be enabled at 
any point, and you shouldn’t rely on the user interface layer to store that 
information for you.  I know *some* Cocoa controls can be used to store state, 
but IMO that’s a bad design pattern, not least because it means the UI could 
diverge from your program’s internal state; and it won’t work for all controls 
in any case as some of them fetch data from your code on the fly (e.g. 
NSTableView or NSOutlineView).

Whether you use bindings or whether you explicitly update your UI is up to you. 
 Neither is hard.

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

Re: disable group of controls

2017-04-05 Thread Keary Suska

> On Apr 5, 2017, at 5:05 AM, J.E. Schotsman  wrote:
> 
> 
>> On 05 Apr 2017, at 11:48, Jack Carbaugh  wrote:
>> 
>> Get a list of the controls then loop through it, setting each enabled 
>> property to false. The container holding them will hold a reference to them
> 
> That way you lose the latent enabled state.
> When the embedder is set to disabled some of the sub controls may already be 
> disabled.

How so? You can have multiple enabled bindings on a control, and if any return 
NO the control stays disabled. If you aren’t using bindings for the “latent” 
state, the responsible controller can observe the group disable property and 
adjust accordingly.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

Re: disable group of controls

2017-04-05 Thread Alastair Houghton
On 5 Apr 2017, at 10:45, J.E. Schotsman  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:



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

Re: disable group of controls

2017-04-05 Thread Jonathan Mitchell

> On 5 Apr 2017, at 12:05, J.E. Schotsman  wrote:
> 
> 
>> On 05 Apr 2017, at 11:48, Jack Carbaugh  wrote:
>> 
>> Get a list of the controls then loop through it, setting each enabled 
>> property to false. The container holding them will hold a reference to them
> 
> That way you lose the latent enabled state.
> When the embedder is set to disabled some of the sub controls may already be 
> disabled.
You could create a simple queue for each control (an associated object might be 
handy here) and then push and pop the sub control state.

J
___

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


Re: disable group of controls

2017-04-05 Thread J.E. Schotsman

> On 05 Apr 2017, at 11:48, Jack Carbaugh  wrote:
> 
> Get a list of the controls then loop through it, setting each enabled 
> property to false. The container holding them will hold a reference to them

That way you lose the latent enabled state.
When the embedder is set to disabled some of the sub controls may already be 
disabled.

Jan E.

___

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


Re: disable group of controls

2017-04-05 Thread Jonathan Mitchell

> On 5 Apr 2017, at 10:45, J.E. Schotsman  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 don’t think you are missing anything.
There is no built in support for this AFAIK.

For disabling groups of controls I generally just bind the relevant controls 
enabled property to a bool flag.

J
___

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

Re: disable group of controls

2017-04-05 Thread J.E. Schotsman

> 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?

Jan E.
___

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


disable group of controls

2017-04-03 Thread J.E. Schotsman
Hello,

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.

TIA,

Jan E.
___

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