Text Editing with NSCollectionView - objective-c

I've been banging my head against the wall (Cocoa) for about a week with this problem and wanted to get some advice if possible.
I'm trying to provide a list of NSTextFields to the user representing a list of features – letting them add additional textfields using an 'Add' button. This is part of a bigger form and the user should just be able to tab through the whole form (including the list)
I implemented the above using an NSCollectionView which pretty much worked except tabbing seemed to intermittently stop working in the NSCollectionView for reasons I can not figure out. You'll be hitting tab, cycling through normally when all of a sudden the collection view is skipped altogether, or sometimes if you're in a specific text field in the collection view hitting tab will just highlight the text but will never jump to the next field without mouse clicking outside the collection view. I was wondering if anyone had experienced this before... or has any advice for debugging something like this? I've attempted logging what the nextResponder is every time a control becomes the responder and there doesn't seem to be any pattern explaining why tabbing just stops working suddenly and then begins again.
There are 3 TabViews with a collection view in each. I have been wondering if that may be causing an issue?
Thanks for any help anyone can provide.

OK, after all this time I may have solved this (Tentatively anyway... I haven't seen any problems on numerous run-throughs and it usually occurs at least once every time before)
Turning on Auto Recalculates View Loop on the Main Window seems to have resolved whatever was happening. I have to admit I don't completely understand why, except that maybe because of the tab views and collections views the key loop needs to be recalculated to keep everything in sync. I'm thinking I need to do more research into exactly how the key loops work...

Related

Optimizing QListView update

I'm writing a logging application which is using a QListView with custom QStandardItems to display the log data. I have implemented filters in the app that will color the matching rows differently and when changing a filter I have to manipulate every item in the list, which after a while gets very slow. I'm not sure what's causing this yet, but I wonder if it could be that it repaints after every item change. If that is the case, could I somehow tell QT to not repaint until I'm done manipulating all the items?
Thanks for any help!
For helping others, I could add that I fixed this by implementing my own view that handles the paint event itself and only paints the rows currently visible on screen. This makes it extremely fast and no internal QT view seem to be able to do something similar.

Window doesn't render as expected, controls gets messed up

I have a NSWindow with autolayout, There is one view based NSTableView with few controls like images and labels . Once in a while the window comes ugly, means all the constraints doesn't work, and the text fields, images just loose their places.
All the controls inside the tableView are seen in (0,0). But only for few rows, for other rows it work perfectly, however all rows contains same controls.
This is happening only for the first time specially in OSX 10.10 when installing from DMG, if I reopen the window again then every thing look OK, no overlapping of text and other controls.
Please help to understand the issue, or any suggestion to fix.

Recreating the whole UICollectionView vs invalidating the UICollectionView layout on an orientation change

I have a horrible problem that is worthy of a separate stackoverflow question. Perhaps I can save time by asking a different question:
What are the downsides to recreating the whole UICollectionView layout on every device rotation rather than invalidating the UICollectionView layout with invalidateLayout?
Bare in mind that its a small view with a maximum of 6 text based cells - not a lot of data.
This question is a follow on from this one. I implemented the UICollection view and everything is working except the first two buttons inside the cells aren’t changing width on a orientation change, its a mess. Its almost like the method to update the cells is definitely being called but with the data from the last orientation view. Even after lots of debugging I'm still unsure exactly what the problem is.
Update
I managed to solve my nightmare with the information from this answer and the actual code from this answer. But if someone can still answer this question it would be helpful and interesting, I still want to know the answer!

How can I fix the flicker occurring when selecting an NSCollectionViewItem?

I've got an NSCollectionView which houses three columns of NSCollectionViewItems. In each of the NSCollectionViewItem prototype views, I have a single NSImageView. As far as I'm aware, this is a fairly standard setup. I think the problem stems from my use of a popover to present the collection view, but I'm honestly not sure. Basically, the problem I'm having is that when I click on one of the aforementioned NSCollectionViewItems to mark it as "selected," every once in awhile it flickers/flashes. It's not a total deal-breaker, but it's annoying enough to make me post this question.
Coming from the HTML/CSS/JS game, I started to think of all the ways I would prevent the flicker when building stuff with web technologies. My first thought was to make certain parts of the NSCollectionView (and subviews) layer-backed. I figured that by doing the drawing via layers or just setting the collection view to be layer-backed period, it would render better, kind of like GPU-enhanced animations in CSS (e.g. no sub-pixel antialiasing, enables z-depth, etc.).
So, I subclassed NSCollectionView and added a [self setWantsLayer:YES] in the
-(id)initWithCoder:aDecoder method. I was right! It removed the flickering altogether. Also, the scrolling became much smoother. However, in the process of making the flicker go away, everything else started messing up. The popover would take about 10s to load (vs. ~500ms originally), items would do weird overlapping things, etc.
My question to you all is this: what should I do? If anyone could help a brother out, I'd really appreciate it.

UTextView autocomplete vs live suggestions iOS

If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?
This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.
In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.