My NSCollectionView uses a custom NSCollectionViewItem which contains 2 NSComboBox, 1 NSTextField and 1 NSDatePicker. When running my app and displaying multiple NSCollectionViewItems, I am able to tab through the comboboxes and the textfield of the first item, but none of the items that follow. If I select the textfield in the second or third item and hit the tab key, nothing happens.
I would like to tab through each component in my NSCollectionViewItem and then continue through to the next component in the next NSCollectionViewItem. I expected this to be the default behavior.
Because it works for the first item in my NSCollectionView, I know that it can work for the rest.
Is there something I need to set while NSCollectionView is displaying the items?
Switch on Recalculates View Loop of the window. Side effect: nextKeyView of the views isn't used.
Related
I have a Window with multiple NSTableView elements where I can select rows.
Now when I press a button an action is triggered and I need to do stuff depending on which element in which NSTableView was selected before the click.
How do I do this?
I can check using the selectedRowIndexes but this is set for all tableViews that has selected items and not only for the one that the user wants the action for. (the last one that was selected)
How would I be able to create a button that works similarly to the add phone button in the contacts app? As shown below, to replicate it, I have a button on the right side that the type is Add Contact (appears as a plus in a circle) and on the right is a label. I then put them together in a stack view.
How does the contacts app have one large (bar) button that holds the image and the text? When tapping on the button (in the contacts app) it highlights the whole bar. This makes me believe that might have done this using a UITableView.
What's the best way to create a similar (bar) button as they did? Would this be easier to replicate if I used a UITableView instead?
It's definitely a tableView.
They either constrained button's top to an empty tableView's bottom or they made this as an integral tableView and each time you didSelectRowAt it inserts a row at known position.
Suppose they either use a DataSource delegate method for rows insertion or a custom-made function wrapped in tableView.beginUpdates() and tableView.endUpdates() (reloads the table with animation)
you should not use stackview to wrap both button and right text.because you also need tap event.and stack view not giving tapping event.
I think you should place your button and label inside UIView and than Assing UIControl as Class in Inspecter(not UIView).than Controll drag from Your View to Class File and select TouchUPinside event.disabel user interaction of both button and Label otherwise event will not Fired.
and than Add above UIControll and other Component to either tableView or Vertical StackView.
I working with swift 4 for macOS and have a NSTableView with custom Cells.
In my row are two textfields (style: borderless and no background color)
Normally, you click on a textfield and it will directly be editable.
In my case, you click on the textfield and after a short delay it will be editable.
But I don't understand why is there such a delay.
Have anybody an idea?
Better Example
My tableview with Custom Cell View (delay problem)
Another tableview without Custom Cell View (no delay problem)
I hope you can see the difference. I do both situations with the same steps.
Select Row (click)
Select textfield (click)
Seems like you’re selecting the table view cell first. Try tableView.allowsSelection = false
Iv got a mac application that uses a table view on the left side of the window as the navigation, and then another table view on the right that shows the relevant information.
I do this by just checking what cell is selected on the left table view and use that to update the information on the right.
The problem is when the table views load they dont have a row selected, the selected row shows up as -1 (AKA nothing) i need the table view to have a row selected when the view loads, not just after someone selects it. Kinda like the finder window, when you open the application it has a row already selected.
And no i dont want to just change the background color of the cell so it looks selected when the app opens, because that wont fix the -1 problem.
You cans select a row programmatically using the API on NSTableView:
func selectRowIndexes(_ indexes: NSIndexSet,
byExtendingSelection extend: Bool)
Let us say, you want to pre select the 0th row, then you can need to call the above API as in viewDidLoad method:
tableView. selectRowIndexes(NSIndexSet(index:0) byExtendingSelection:NO)
I want to add a plus button outside my table view cell (on the left side), but the button should get scrolled if I am scrolling the table. Does anyone has a solution for this??? Also, there are 8 different sections in my table. There is no need to show that plus button for the first 7 sections, but there is a plus button in the 8th section clicking on which will increase the number of sections by 1. (the catch here is that the plus button is NOT INSIDE THE CELL and there are different sections where we will not show the plus button, so no UNIFORMITY).
I belive that the best solution to this is to create a custom section header (or footer) view and put the button there. It will "look" like it's outside the table, but it will be inside the given view.
In your case, only inside the section header/footer of section 7.
That button will scrool along with the table, as the section header/footer will.
Or, alternatively, you could have an "empty" section 8 (with no rows, but with a header) and display the button there. If you want the button displayed, you should return the number of section as "8", if you want the button hidden, return section count as "7".