I programatically create a series of NSTextField cells and they have serious problems that have blocked all development for almost a week. Hopefully someone can help:
1. Undo is totally messed up. First, even though I did not setAllowsUndo in the fieldEditor it is logging undo typing events. It would be fine if it worked, but whenever I click in another cell, a subsequent undo request fails and logs a message about substring out of range. (it performs incorrectly without an error if the new cell has longer text the the original, but fails with the error message if the text is shorter).
2. I have my own undo action when the contents of a field are done editing and committed to my data model, but that undo action never appears as an undo event. When I click in a new cell and the data can be verified as committed, but the undo menu remains "Undo Typing" and never takes my set action name. Furthermore selecting undo does not undo my committing action but just fails as in item 1. I even tried to remove all undo actions before inserting my action and yet the "Undo Typing" remains and mine is now inserted?
3. Finally, I linked all NSTextFields for tabbing with setNextKeyView, but it does not work. Tabbing in a field does not advance along the settings I made (note: it was done programmatically and not by links in interface builder due to dynamic nature of fields in this view). I even tried to set the window to auto calculate the loop and explicitly called recalculateKeyViewLoop but nothing ever gets linked up during events (although I could verify by looping through the nextKeyView settings that my code option did set all the links).
This is crazy. I have done all these tasks before (except programatic cells) and they always work. Now nothing works and nothing makes sense (like removing all actions not removing all actions, setting next key view not setting next key view, set an undo action no setting an undo action, and auto calculating key loop not auto calculating the key loop).
My programmatically created NSTextFields are all subviews of the documentView of a custom NSScrollView. They are created with the following code and added as subviews of that documentView.
- (id)initForStructure:(id)record { NSFont *theFont;
if(self=[super initWithFrame:NSMakeRect(hoff,voff,72.,22.)]) { [self setStringValue:[record contents]]; if((theFont=[[gcLibrary editingPrefs] fontNamed:@"Editing Font"])) [self setFont:theFont]; [self setDelegate:self]; [self setStructure:[record structure]]; changed=NO; } return self; }
P.S.: I am in Europe for 2 months and my postings tend to be 1:00-5:00AM Apple time. Hopefully someone will see this message.
--------------- John Nairn (1-801-581-3413, FAX:1-801-581-4816)
|