Post

Replies

Boosts

Views

Activity

Reply to Binding a NSSearchField to a NSArrayController
Hi, I'm still stuck on that. I tried to add another condition OR : searchField.bind(.predicate, to: arrayController, withKeyPath: NSBindingName.filterPredicate.rawValue, options: [.predicateFormat: "(title contains[cd] $value) OR (artist.name CONTAINS[cd] $value)"]) It works : Bur it is not what I'm looking for. I'd like to concatenate to have all the tracks which contains the string in the artist, title and album, like in the Music app : How to do that ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Subclassing a NSSearchField
Thx for your answer, and yes, I had to add a selector... Not very intuitive but it is like that. So Now I can manage my item selection and do my filter but I'm looking for how to achieve that. I wrote a message here but no answer yet. Can U help me ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Subclassing a NSSearchField
Hi, So basically, I just added a NSMenu to my NSSearchField : let theMenu = NSMenu(title: "Filters") let theMenus = ["all", "artist", "title", "album"] for theName in theMenus { let theMenuItem = NSMenuItem(title: theName, action: nil, keyEquivalent: "") theMenu.addItem(theMenuItem) theMenuItem.isEnabled = true } searchField.searchMenuTemplate = theMenu Problem : the items are disabled and I don't know how to enable it : What's wrong ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Subclassing a NSSearchField
Hi, A few mouths later, I just saw your answer... Thx for that ! I'm back on my project which use the ITLibrary (I'm speaking about it here) Everything works like a charm with my NSSearchField and now I'd like to add a NSMenu to have a more option to filter. I took a look to your link but I'm not sure to understand how to add the NSMenu... I have to set a NSMenu to the cell of the NSSearchfield ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Binding a NSSearchField to a NSArrayController
Hi, Back on this post. So I took a look on the Internet and I found some interesting sources. I found how to bind the NSSearchField : searchField.bind(.predicate, to: arrayController, withKeyPath: NSBindingName.filterPredicate.rawValue, options: [.predicateFormat: "title CONTAINS $value"]) And as U can see it works like a charm when I search in the ITMediaLibItem object title : But I'm not familiar with the notation and I didn't find all the possibilities. I notice if I had [cd] to the CONTAINS keyword, whatever the case the string is which is great : What are the other possibilities ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Adding / Removing items from a NSTableView
Back ! So I have the adding / removing actions. What about filtering ? I'm using a NSArrayController now which has binding capacities. To bind it to the NSTableView, I simply do : tracksListTableView.bind(.content, to: arrayController, withKeyPath: "arrangedObjects", options: nil) Et voila ! I tried to bind the NSSearchField in the same way : searchField.bind(             .predicate,             to: self.arrayController,             withKeyPath: NSBindingName.filterPredicate.rawValue,             options: [.predicateFormat: "col CONTAINS[cd] $value"] But it fails when I start to type in the searchField : Multiline Error setting value for key path filterPredicate of object <NSArrayController: 0x6000036fc2a0>[object class: NSMutableDictionary, number of selected objects: 1] (from bound object <NSSearchField: 0x14c710d90>): [<ITLibMediaItem 0x600001013580> valueForUndefinedKey:]: this class is not key value coding-compliant for the key col. How to fix that ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Binding a NSSearchField to a NSArrayController
Hi, I'm still stuck on that. I tried to add another condition OR : searchField.bind(.predicate, to: arrayController, withKeyPath: NSBindingName.filterPredicate.rawValue, options: [.predicateFormat: "(title contains[cd] $value) OR (artist.name CONTAINS[cd] $value)"]) It works : Bur it is not what I'm looking for. I'd like to concatenate to have all the tracks which contains the string in the artist, title and album, like in the Music app : How to do that ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Subclassing a NSSearchField
Thx for your answer, and yes, I had to add a selector... Not very intuitive but it is like that. So Now I can manage my item selection and do my filter but I'm looking for how to achieve that. I wrote a message here but no answer yet. Can U help me ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Subclassing a NSSearchField
Hi, So basically, I just added a NSMenu to my NSSearchField : let theMenu = NSMenu(title: "Filters") let theMenus = ["all", "artist", "title", "album"] for theName in theMenus { let theMenuItem = NSMenuItem(title: theName, action: nil, keyEquivalent: "") theMenu.addItem(theMenuItem) theMenuItem.isEnabled = true } searchField.searchMenuTemplate = theMenu Problem : the items are disabled and I don't know how to enable it : What's wrong ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Subclassing a NSSearchField
Hi, A few mouths later, I just saw your answer... Thx for that ! I'm back on my project which use the ITLibrary (I'm speaking about it here) Everything works like a charm with my NSSearchField and now I'd like to add a NSMenu to have a more option to filter. I took a look to your link but I'm not sure to understand how to add the NSMenu... I have to set a NSMenu to the cell of the NSSearchfield ? Thx.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Binding a NSSearchField to a NSArrayController
Hi, Back on this post. So I took a look on the Internet and I found some interesting sources. I found how to bind the NSSearchField : searchField.bind(.predicate, to: arrayController, withKeyPath: NSBindingName.filterPredicate.rawValue, options: [.predicateFormat: "title CONTAINS $value"]) And as U can see it works like a charm when I search in the ITMediaLibItem object title : But I'm not familiar with the notation and I didn't find all the possibilities. I notice if I had [cd] to the CONTAINS keyword, whatever the case the string is which is great : What are the other possibilities ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Adding / Removing items from a NSTableView
Back ! So I have the adding / removing actions. What about filtering ? I'm using a NSArrayController now which has binding capacities. To bind it to the NSTableView, I simply do : tracksListTableView.bind(.content, to: arrayController, withKeyPath: "arrangedObjects", options: nil) Et voila ! I tried to bind the NSSearchField in the same way : searchField.bind(             .predicate,             to: self.arrayController,             withKeyPath: NSBindingName.filterPredicate.rawValue,             options: [.predicateFormat: "col CONTAINS[cd] $value"] But it fails when I start to type in the searchField : Multiline Error setting value for key path filterPredicate of object <NSArrayController: 0x6000036fc2a0>[object class: NSMutableDictionary, number of selected objects: 1] (from bound object <NSSearchField: 0x14c710d90>): [<ITLibMediaItem 0x600001013580> valueForUndefinedKey:]: this class is not key value coding-compliant for the key col. How to fix that ? Thx.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21