NSPopUpButton not updating selectItem - macos

I have a NSPopUpButton where I'm preselecting item in the menu and is been selected but is not showing as selected. Here is my code:
[self.categoryMenu selectItemWithTitle:#"cineRush"];
Here is how is showing:
But here is how show if I click on the NSPopUpButton:
But it show "cineRush" as selected item.
Any of you knows why this is happening or how can this fix?

Related

Edit button for tableview

Can anyone offer assistance with adding a delete button to a tableview in xcode? I can create the button but cannot get it to delete anything in the table. I'm using the default code that comes with the Master Detail Application but have changed the content of the table using an NSObject.
This should be the default behaviour of the edit button.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
This will allow you to click and delete any item in the list after it is pressed.
Unless I am misunderstanding how you are using the table item list.

Listbox bindind error scrolling

I have a listbox(JumpListBox) with ~500 items.
Listbox template is a grid which have two columns - checkbox and image;
To reproduce problem: I've checked two items, then I do scrolling, then I can see that checkbox not corresponding to item which was selected. When I do scrolling back to the item I was selected I see that items are not selected, but other items was selected.
I recorded a video and you can see a problem.

calling an action on clicking NSPopupButton

I have a NSPopupButton that displays a drop down menu when clicked. This menu is populated from an NSArray. Now if I click on one of the items in the drop down Menu, I can select it and determine what is selected etc.
What I want to do is when the user clicks on the NSpopupbutton, update the drop down menu and then have the user pick one of the items.
I am having trouble finding how to call a IBAction method when I simply select the drop down menu ( not clicking any one item in it). The clicking of an item in the menu results in an IBAction, but I want just the clicking of the down arrow in the NSPopupButton to trigger an action. Any ideas ? Thanks.
The NSPopupButton sends an NSPopUpButtonWillPopUpNotification when clicked. Have your controller object listen for that notification and respond by updating the dropdown menu.
The accepted answer worked, though now it's called NSPopUpButton.willPopUpNotification
In Swift 4.x, my code looked like:
NotificationCenter.default.addObserver(self,
selector: #selector(dropdownMenuOpened),
name: NSPopUpButton.willPopUpNotification,
object: nil)

Flex 4 DropDownList Selected Item

the standard behaviour of a Flex dropdownlist is to disable the currently selected item from the list. Does anybody know how to override this to allow the user to re-select the selected item (if they so desire)?
NOTE: I don't want there to be a selected item in the list but I still want the selecteditem property to be set in the dropdownlist control, otherwise how will I know what has been selected. This is slighly trickier than it sounds...unless I have missed something...
Thanks
Mark
I'm not sure I understand the question but you can listen to close event of the component :
Dispatched when the drop-down list closes for any reason, such when the user: Selects an item in the drop-down list. Clicks outside of the drop-down list. Clicks the anchor button while the drop-down list is displayed.
So, you can access the component and gather the selectedIndex, selectedItem properties.
I guess what I'd like to know is that why you want to "re-select", possible to trigger something again but I'd try close event...

NSCollectionView get selected item on button click

I have a NSCollectionView is bound to an NSArrayController that has an NSMutableArray as content. Items in the NSMutableArray are displayed as they should.
I have an WindowController class that holds a reference to the NSMutableArray. There is also a button that causes a buttonClicked message to be sent to my WindowController.
Now inside buttonClicked I want to know what item is selected in the NSCollectionView. How do I do this? I have no reference to the NSArrayController otherwise I could have asked it by sending selection. I've studied some sample code but to no avail.
How can I get a reference to the currently selected item in the NSArrayController?
if the NSCollectionView is getting its content from the NSArrayController, as there is a binding set in IB on content or you have programmatically bound these, there is also a binding available on the collectionView's selectionIndexes, which when bound to the arrayController will give you 'a reference to the currently selected item' in the arrayController and the collectionView.
NSCollectionView's itemAtIndex, handed the currently selected item's index, will get you the actual item that is selected.
is the actual item that is selected what you are looking to obtain a reference to?

Resources