discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cant disable Item of NSPopUpButton


From: H. Nikolaus Schaller
Subject: Re: Cant disable Item of NSPopUpButton
Date: Fri, 20 Sep 2024 18:57:57 +0200

Hi,

> Am 20.09.2024 um 19:20 schrieb Sebastian Reitenbach 
> <sebastia@l00-bugdead-prods.de>:
> 
> Hi,
> 
> I've a NSPopUpButton with some items. Some of them I want just to be disabled.
> To do so, I thought I can just get away with:
> 
> [[self.popupButton itemWithTitle: @"Item 2"] setEnabled: NO];
> 
> but that is not the case.
> 
> Is that supposted to work that way, if at all? If so, any hint what I'm doing 
> wrong?

I think (based on Cocoa experience) you must implement some validateMenuItem: 
or similar method for the target of the popup button. So that it can return YES 
or NO on demand.

To make it dynamical I think the validateMenuItem: is passed the item in 
discussion and you can make decisions based on e.g. [item action] or [item 
title] (not recommended) or [item representedValue]. This is a little similar 
to the dataSource of an NSTableView. You never set values directly in the 
NSTableView but it asks some other object to provide them but only on demand by 
whatever algorithm fits.

This is called when a users opens the menus and depending on the result the 
setEnabled: is called automatically (and overwrites your changes).

BR,
Nikolaus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]