another Core Data and Undo Question
i have a core data app that supports both real time events and user interaction. some of the user interactions can generate an undo stack similar to the following: beginUndoGroup beginUndoGroup core data action core data action endUndoGroup myAction endUndoGroup now some of the real time events can cause the target of myAction to be deleted and i can easily remove this from the undo stack. but that leaves a nested group which is no longer meaningful and it leaves the undo menu action name referring to the deleted myAction is there anyway to delete the entire group (including the nested core data actions)? if so, how? alternatively, can anyone suggest an approach to deal with this situation? thanx, ken p.s. i don't know if its relevant or not, but i have setGroupsByEvent set to NO and i begin an undo group when i'm ready to execute a user action. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
problem with core data and uno
i'm having a problem with core data and undo. here is the simplified situation. i've got subclasses of NSManagedObject: object A and object B. object A has a to-one relationship to object B. the reciprocal relationship in object B is a to many relationship. i.e., object B can refer to multiple object A s, but object A can only reference one object B. i then edit object A (using a sheet to enable editing multiple properties simultaneously) to refer to a different object B. this is an undoable user action. later on i programmatically change one of the properties of object B. this is NOT undoable, and the change is done as follows: [moc processPendingChanges]; [[moc undoManager] disableUndoRegistration]; b.propertyB = blah; ... [moc processPendingChanges]; [[moc undoManager] enableUndoRegistration]; now if i subsequently undo the first set of edits to object A, propertyB of object B gets reverted back to the value it had prior to this entire sequence. this strikes me as wrong! while the first set of edits (to object A) did change the to many relationship that object B had, they did not touch the propertyB property and should not have reverted it. it seems to me that core data is saving the entire state of object B, instead of simply the state of the to many relationship. can anyone confirm my suspicions? or suggest that possibly this is a bug in my app -- i have spent about 12 hours trying to track this down in my app, and haven't found anything? or if my suspicions are correct, can anyone suggest a work-around? or is there some other way to do this? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: find panel buttons not enabling
i have now verified (via an extremely trivial cocoa application) that the buttons in a Find panel are not enabled if the first responder is an NSTextView that appears in a sheet (which is the key window). note that the find functions (e.g., find next/previous, use selection for find) all work properly. can anyone tell me if this is by design (e.g., some manifestation of the HIG) or if this is a bug? this is built on and for 10.6.2. in any case, can anyone suggest some way to get the Find panel buttons to be enabled if the first responder is an NSTextView in a sheet. thanx, ken At 12:23 PM -0700 3/19/10, kvic...@pobox.com wrote: if i have an NSTextView in a sheet and open the find panel, the buttons remain disabled. however, the find commands from the menu work fine. is the find panel not supposed to work if the key window is a sheet? or is this a known bug? any suggestions as to how to get the buttons to be properly enabled? this is on built on and for 10.6.2. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
find panel buttons not enabling
if i have an NSTextView in a sheet and open the find panel, the buttons remain disabled. however, the find commands from the menu work fine. is the find panel not supposed to work if the key window is a sheet? or is this a known bug? any suggestions as to how to get the buttons to be properly enabled? this is on built on and for 10.6.2. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
xcode type completion for NSTextView
i'd like to do xcode type completion for a NSTextView that i display in a sheet. by xcode type completion i mean: multi-column display reduce selection with subsequent typing escape cancels completion i don't beleive the current cocoa completion supports this and that it will be necessary to provide my own borderless window with a multi column table that i populate myself. is this correct? or is it possible to do xcode type completion using only the existing delegate methods for completion. (fwiw, this is snow leopard and above only) thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: dragging to trash folder problems
kyle, thanx for the response. see below for a followup question. At 10:36 PM -0500 12/26/09, Kyle Sluder wrote: On Sat, Dec 26, 2009 at 5:24 PM, kvic...@pobox.com kvic...@pobox.com wrote: however, if the user drags an object to the trash icon, and then subsequently drags to and drops on the (popped) opened trash folder, i no longer receive the NSDragOperationDelete operation in -draggedImage:endedAt:operation: and hence cannot detect that this should actually be a delete and the opened trash folder remains open on the desktop. This sounds like a bug. You should file it at http://bugreport.apple.com. If the Dock is going to report a drag-to-Trash as a delete operation, then the Finder should report a drag-to-Trash-folder as a delete operation as well. reported as 7499789 1) how can i detect that the user dropped into a (popped) opened trash folder? If you are able to drag to a folder at all, you must be providing a file or a promise pasteboard item. In that case, you should be able to tell if the destination folder is a Trash folder (either NSWorkspace or some Carbon API). Then you can perform the delete. i am not providing either a file or a promise (at least not that i know of). in my table's data source implementation of -tableView:writeRowsWithIndexes:toPasteboard: i supply one (or more) private pboard types and i also provide NSRTFPboardType and NSStringPboardType data that enables dragging (rich) text to text files and which create text clipping files when dropped in a folder or on the desktop. for testing purposes, i implemented -tableView:setObjectValue:forTableColumn:row: and -pasteboard:provideDataForType: in my datasource, but neither is called. ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
dragging to trash folder problems
i've implemented -draggedImage:endedAt:operation: and i check if the operation is an NSDragOperationDelete to detect drags to the trash, and if so, i then appropriately delete the dragged object from my app's document. this all works fine as long as the user drags the object to the trash icon in the dock. however, if the user drags an object to the trash icon, and then subsequently drags to and drops on the (popped) opened trash folder, i no longer receive the NSDragOperationDelete operation in -draggedImage:endedAt:operation: and hence cannot detect that this should actually be a delete and the opened trash folder remains open on the desktop. not only that, but if the user drops in the (pop) opened trash folder, since i don't perform the delete, the user can again drag the same object to the trash icon in the dock and this opens a second trash folder. this can be repeated many times, resulting in many opened trash folders on the desktop. my questions: 1) how can i detect that the user dropped into a (popped) opened trash folder? 2) is the behavior of (popping) open multiple instances of the trash folder a (known) bug? this is on leopard 10.5.8. ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
re: NSSpellChecker and checkSpellingOfString problems
i don't know if this is your problem or not, but i don't see the red underline when i accade until i type a word delimeter (e.g. a space or comma) after it. do u perhaps need to make sure the string u r passing to the spell checker has appropriate beginning and ending delimeters? ken At 11:22 AM -0800 12/3/09, keithblo...@yahoo.com wrote: Try typing accade into TextEdit (I'm assuming English as the language here, of course). It is underlined in red, and ctrl-clicking on it brings up a list of suggestions. So the system recognises it as a misspelling, a word that it doesn't know. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
disabling Open Recent menu items
i need to disable opening any files via the Open Recent menu items until the user has specified some information that i save in my app's prefs. this situation can occur if the user has deliberately or accidentally deleted the prefs. now, i can (and do) override -[NSDocumentController openDocumentWithContentsOfURL:display:error:] which takes care of the situation in which the user double clicks a file in the finder. however, in addition to this, i would like to dim/disable any files that happen to be in the Open Recents file (sub-)menu. for the time being, i'm overriding -[NSDocumentController validateMenuItem:] and seeing if the action for the passed in menuItem is _openRecentDocument:. but since this is an undocumented api, i prefer to accomplish this in a more legal manner, but i don't know what that is. can anyone suggest a legal way to disable the items in the Open Recent menu? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
restoring NSSplitView divider's position
i have a multi-document, multi-window app and i'm getting ready to use NSSplitView for the first time. from reading the docs and searching at cocoadev, i don't see how to get the current position of the divider so that i can save it, and later restore it on subsequent launches of my app/document/windows. i can't use autoSave as this is a document/window attribute and not an attribute of the app. ie, each window for each doc can and should remember the divider's position. thanx, ken ps. i do see the method for setting the divider's position... i just don't see how to get the current position for saving. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
debugging a 64 bit app
with a 32 bit app, when i hit a breakpoint in gdb, i could select a stack frame and enter the following into the gdb console: (gdb) po *(int *)($ebp+XXX) where XXX was 8 to see the receiver of the message, 16 to see the first meaningful parameter, etc. however, i'm not building a 64 bit app and using synthesized iVars and when i type the above on the gdb console, i get: Argument to arithmetic operation not a number or boolean. what is the proper way to see stack parameters with cocoa 64 bit apps with gdb? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: incorrect checksum for freed object
At 6:31 PM -0700 7/31/09, Shawn Erickson wrote: On Fri, Jul 31, 2009 at 3:39 PM, kvic...@pobox.comkvic...@pobox.com wrote: where interface and device are declared as follows: @property ( assign, nonatomic) IOUSBDeviceInterface300** device; @property ( assign, nonatomic) IOUSBInterfaceInterface300** interface; Why are you use a pointer to a pointer (**) in above? I ask because doing so seems a little strange and hence leads me to think you may have a misunderstanding of pointers, etc. in some of the API you are calling. -Shawn i'm using pointer to pointer (sometimes called handles) because that is what is required when using the usb aspects of the IOKit as demonstated in apple's sample code. ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
incorrect checksum for freed object
(i'm not sure if this is the right list for this question or not, as i am developing a cocoa application using IOKit. if this isn't the right list, could someone please tell me the right list. thanx.) i'm just starting on developing a core data document base app that talks to a usb device. sometimes, but not always, i'm getting crashes when i'm either releasing my IOUSBDeviceInterface300 or my IOUSBInterfaceInterface300. the error i get on the console is: malloc: *** error for object 0x102662970: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug and i have set that breakpoint. the stack trace at the time is: #0 0x83d7aa51 in malloc_error_break #1 0x83d75ad0 in szone_error #2 0x83cb5571 in tiny_free_list_add_ptr #3 0x83cb28cf in szone_free #4 0x025876ba in IOUSBDeviceClass::~IOUSBDeviceClass #5 0x02586f0d in IOUSBIUnknown::release #6 0x1f1a in -[BaseUSBInterface releaseResources] at BaseUSBInterface.mm:154 in response to: err = (*(self.interface))-Release( self.interface); or err = (*(self.device))-Release( self.device); where interface and device are declared as follows: @property ( assign, nonatomic) IOUSBDeviceInterface300** device; @property ( assign, nonatomic) IOUSBInterfaceInterface300** interface; and synthesized. i am running in 64 bit mode and have NOT declared my own iVars for these. these errors don't happen every time and i've yet to be able to determine a pattern that causes them. i realize that this is some sort of memory corruption problem, but i'm at a loss as to how to find it. i do have NSZombieEnabled set to YES and CFZombieLevel set to 3. can anyone one offer suggestions as to how to find this problem. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: incorrect checksum for freed object
At 5:01 PM -0600 7/31/09, Nick Zitzmann wrote: On Jul 31, 2009, at 4:39 PM, kvic...@pobox.com wrote: these errors don't happen every time and i've yet to be able to determine a pattern that causes them. i realize that this is some sort of memory corruption problem, but i'm at a loss as to how to find it. i do have NSZombieEnabled set to YES and CFZombieLevel set to 3. can anyone one offer suggestions as to how to find this problem. Turn on Guard Malloc, which will force your app to crash if something writes into freed memory. Be ready to do something else while it's running, though, because Guard Malloc makes your app run super slow, especially if it uses a lot of RAM. Nick Zitzmann http://www.chronosnet.com/ thanx nick, my app is still in the early stages, and thus small enough that turning on guard malloc isn't that bad. of course now that its turned on, i no longer get the crashes! i guess i'll run in this mode for a while. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[NSEvent data1]
i'm building a 64bit app. in response to USB input, i create and post an application defined event. for the data1 field, i pass the address of an NSMutableDictionary as follows: ... data1: (NSInteger)dataDict ... in my application object's sendEvent override, i'm only getting (via [anEvent data1]) the bottom 32 bits of the address i passed in. the data1 method of NSEvent is defined to return an NSInteger, as is the data1 parameter of the NSEvent method otherEventWithType, and if i examining the value of data1 after i've created my custom event and posted it (but prior to receiving/processing it in sendEvent), it contains the proper 64 bit value. so it appears that somewhere between posting the event and its getting processed by [NSApp sendevent:] the parameter is getting truncated to 32 bits. is this a bug in the 64 bit runtime? or a bug in my understanding? and if not a misunderstanding on my part, anyone know of a workaround (other my simply decomposing the 64bit address manually into 2 32bit pieces and using data1 and data2)? thanx, ken ps. running on leopard 10.5.7, with Xcode 3.1.3. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: disabling grammar checking
At 6:57 PM -0700 6/29/09, Martin Wierschin wrote: i'm not happy that the framework is changing the name of my menu item from Show SpellingS (as i've specified in IB) to Show Spelling and Grammar. is there some way to globally fix this? (i know i can provide my overrides of showGuessPanel: and validateMenuItem: in specific field editors, etc., but i'm hoping for something that doesn't require me to provide a custom field editor only to fix this.) I think the best solution is to change the menu item's action to a selector only you know about, eg: showKensSpellingPanel:. You could add a category to NSTextView that simply forwards the action to the normal showGuessPanel:. Validation wouldn't work though, unless you want to swizzle the validator method for NSTextView. Perhaps it would be best to have something higher up the responder chain exclusively pick up your custom action, say an NSApplication delegate. That could inspect the first responder and do validation as necessary. this worked fine. thanx, ken It's an unfortunately messy thing any way you do it, especially for such a trifle. agreed! :-( ~Martin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
disabling grammar checking
while it is meaningful to do spell checking in my app, it is never meaningful to check grammar. therefore, i would like the Check grammar checkbox to not appear in the guess panel, or at least be disabled/grayed out. how can i accomplish this? additionally, i'm not happy that the framework is changing the name of my menu item from Show Spelling (as i've specified in IB) to Show Spelling and Grammar. is there some way to globally fix this? (i know i can provide my overrides of showGuessPanel: and validateMenuItem: in specific field editors, etc., but i'm hoping for something that doesn't require me to provide a custom field editor only to fix this.) thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
(as you type) spell checking of an attributed string
in my app, i use a NSTableView to let the user specify headers/footers for use in reports. a row in the table corresponds to a single header/footer line. a single header/footer line is an NSAttributedString, and i allow the user to specify the text and font and size and text color. additionally, the user can select tags from a popup to insert tags in the line that get evaluated when the report is printed. (these tags correspond to things like the print date, user's name, report name, etc.) my model (persistent copy) of a header/footer line stores these tags as a 4 character sequence: %XX% (where XX corresponds to the particular tag). for display in the table, i replace the 4 character sequence with: \x0001EXPANDED VALUE\x0001 ie, a unicode 1, a string meaningful to the user, a unicode 1. this expanded sequence is given its own custom attribute and the string is displayed with a unique background color. (i suspect this is sorta like a token string, but my implementation pre-dates my knowledge of NSTokenField). this has worked well for me, and i successfully deal with my tags as words as far as selection and drag and drop. now i'd like to be able to support spell checking when the user is specifying header/footer lines. and i'd like to be able to support both manually requested spell checking and continuous/as-you-type spell checking. and when performing either form of spell checking, a tag should be treated as a series of space characters. as i already have my own custom field editor for the table, i believe by overriding of -[NSText checkSpelling], i can get user requested spell checking to work. i would simply perform the appropriate call to NSSpellChecker to check a string in which i've replaced my tags with spaces, and i could set the spell state and selection as needed. but i can't think of anyway to have continuous spell checking treat my tags as a sequence of spaces. can anyone (Mr. Davidson? :-)) offer some suggestions? one thing i thought of thus far is to have the spell checker learn and unlearn my sequences whenever my custom field editor becomes the first responder and the user has requested continuous spell checking. this almost works, but fails if the user doesn't have a word break character between my tag and his/her typing. thanx for any help/advice/suggestions/any thing, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: document specific as-you-type spell checking
At 5:04 PM -0700 6/25/09, Douglas Davidson wrote: On Jun 25, 2009, at 5:00 PM, kvic...@pobox.com wrote: is it possible to do document specific (ie, use a document dictionary) as-you-type spell checking? ie, using NSTextFields and NSTextFieldCells, is it somehow possible to specify the spell document tag to be used by the field editor? If you provide a custom field editor, you can override -spellCheckerDocumentTag. thanx. i guess i'll now start modifying the custom field editor's i currently have, and create custom field editors elsewhere where i want as you type spell checking. i was sorta hoping that there might be a private api (to be made public soon), along the lines of -[NSTextView setSpellCheckerDocumentTag]. this would have been a lot easier than having to provide custom field editor's all over the place. oh well thanx, ken Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
document specific as-you-type spell checking
is it possible to do document specific (ie, use a document dictionary) as-you-type spell checking? ie, using NSTextFields and NSTextFieldCells, is it somehow possible to specify the spell document tag to be used by the field editor? thanx, ken ps. i know i've asked this question before in slightly different flavors, but i've yet to receive any replies. i'm hoping perhaps by re-wording, someone will take pity and reply, and either put me out of my misery (of trying to figure out how it should be done), or point me to some documentation/sample code that shows how to do it! :-( ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
continuous spell checking, NSTextView / field editor, document tag
i would like to have continuous spell checking available for many of my text fields and table/outline cells. i realize that this can be accomplished by call -[NSTextView setContinuousSpellCheckingEnabled:] for the appropriate field editor. what i don't understand is how to specify the spell document tag that should be used by the NSTextView. NSTextView has -spellCheckerDocumentTag to get the spell document tag used by the text view, but i don't see a way to set it. have i missed something? from the archives (http://www.cocoabuilder.com/archive/message/cocoa/2006/10/24/173279) states: As-you-type spellchecking is not so easily overridden in Tiger and before; there will be more control available in Leopard. did this control make it into leopard? if so, where is it? i have a multi-document app, and thus, i would like to be able to use a document specific dictionary for each document, and thus, i need to be able to specify the spell document tag to be used for my text fields and table/outline cells. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
spell checking
my multi-document app has many windows and sheets, and there are LOTS of NSTextFields (and subclasses) and editable NSTableViews and editable NSOutlineViews in these windows and sheets. i would like to enable continuous spell checking (in response to a user preference) in a majority of these fields/views/cells. can anyone offer some advice/suggestions as to what might be the best/easiest way to go about this? one approach i've thought of is to override -[NSWindow makeFirstResponder] and if calling super is successful, then check to see if the new first responder responds to setContinuousSpellCheckingEnabled and if so, then turn it on. and while this seems to work, it is a little too inclusive, and i must then find all the places i don't want it on. also, i'm not sure how i'd go about specifying the document tag to be used when a vanilla field editor does spell checking. thanx for any help/pointers/advice, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: highlighting menu item in main menu bar
At 11:10 AM -0700 6/1/09, Peter Ammon wrote: Hi Ken, The menu item unhighlights after the menu item's action is finished. If user input should be blocked while the script is running, then you should register for the NSTaskDidTerminateNotification and then drive the main run loop forwards from within your menu item's action method, until you get the notification. hi peter, so i tried this as follows: register for the NSTaskDidTerminateNotification launch my sub task (that executes a selected applescript) drive the main run loop until my registered notification routine sets a global return from my action method and while this does indeed keep the menu item in the main menu bar highlighted, it seems to block any apple events from being executed within my app. i've been driving the run loop forward as follows: while (!globalVar) [[NSRunloop runloop] runMode: mode beforeDate: [NSDate dateWithTimeIntervalSinceNow: .1]]; where runloop is either currentRunLoop or mainRunLoop and mode is either: NSDefaultRunLoopMode NSRunLoopCommonModes NSConnectionReplyMode NSModalPanelRunLoopMode NSEventTrackingRunLoopMode or [[NSRunloop runloop] currentMode] i believe my code is basically correct for 2 reasons: 1) if i don't do any of this, then the selected scripts work fine, but the menu item in the main menu bar does not remain highlighted, as my action method returns as soon as its launched the subtask; and 2) if i do the above, the subtask eventually times out, the menu item unhighlights, but of course the subtask was unable to execute the applescript. (note that i can [force] quit my subtask via activity monitor and then the menu bar item unhighlights and my app proceeds appropriately.) so... is there some run loop mode i have to be in to allow applescripts/apple events to execute? alternatively, is there some other way to keep the item in the main menu bar highlighted until my subtask completes executing the applescript? thanx, ken On the other hand, if the user can continue using your app as normal, you should not show the menu item highlighted, because the user might want to choose different menu items. On Jun 1, 2009, at 9:34 AM, kvic...@pobox.com wrote: my app has a scripts menu item (in the main menu bar). the items in this menu correspond to applescript files the user has placed in my application support folder. when the user selects one of these menu items, i execute the appropriate script. i execute the script in a (sub) task (NSTask). i do it this way because i discovered (the hard/empirical way) that if an executing script, executes functionality in my app that calls -[NSScriptCommand suspendExecution], then the executing of that script will erroneously terminate early. using a sub task solves this problem. in my app, when i launch this task, i register for the NSTaskDidTerminateNotification and in my notification routine, i display any errors returned. this all works fine... except that as soon as i return from launching the sub task, the menu item (in the main menu bar) for the scripts menu un-highlights. i would like this to remain highlighted until my notification routine is called, in order to provide feedback to the user that his/her script is still executing. is this possible? if so, could someone provide any code and/or documentation pointers? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
highlighting menu item in main menu bar
my app has a scripts menu item (in the main menu bar). the items in this menu correspond to applescript files the user has placed in my application support folder. when the user selects one of these menu items, i execute the appropriate script. i execute the script in a (sub) task (NSTask). i do it this way because i discovered (the hard/empirical way) that if an executing script, executes functionality in my app that calls -[NSScriptCommand suspendExecution], then the executing of that script will erroneously terminate early. using a sub task solves this problem. in my app, when i launch this task, i register for the NSTaskDidTerminateNotification and in my notification routine, i display any errors returned. this all works fine... except that as soon as i return from launching the sub task, the menu item (in the main menu bar) for the scripts menu un-highlights. i would like this to remain highlighted until my notification routine is called, in order to provide feedback to the user that his/her script is still executing. is this possible? if so, could someone provide any code and/or documentation pointers? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Cancel button in NSSearchField
my app contains an NSSearchField in the toolbar of the various document windows. and i have the various predicates of the search field bound to iVars in my app. additionally, i have my own predicate builder that lets the user build complex search predicates. when the user has built a complex predicate, i set the placeholder text of the search field to be Custom Filter. all this works fine. the problem is that in the situation in which there is a custom filter, there is no text for the search field, and thus the cancel button doesn't show. i've worked around this for now by having a Cancel Custom Filter menu item in the search field's menu. is there anyway to get the cancel button to show if the search field has my special (Custom Filter) placeholder text? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: highlighting menu item in main menu bar
hi peter, thanx for the reply. i believe i understand your reply. i've never driven the run loop forward by hand before, but i think i could figure that out. but before i embark down that path, some quick questions that perhaps you could help me with: 1) if the executing script (from the sub task) causes my app to display a dialog that requires user input, would this be blocked by driving the run loop manually from within the initiating menu item's action method? 2) the reason i went to using a sub task was because of problems with -[NSScriptCommand suspendExecution] (see below). do you know if i might have similar problems if i'm driving the run loop manually? (or am i destined to go down this path and see what happens? :-( ) thanx, ken At 11:10 AM -0700 6/1/09, Peter Ammon wrote: Hi Ken, The menu item unhighlights after the menu item's action is finished. If user input should be blocked while the script is running, then you should register for the NSTaskDidTerminateNotification and then drive the main run loop forwards from within your menu item's action method, until you get the notification. On the other hand, if the user can continue using your app as normal, you should not show the menu item highlighted, because the user might want to choose different menu items. On Jun 1, 2009, at 9:34 AM, kvic...@pobox.com wrote: my app has a scripts menu item (in the main menu bar). the items in this menu correspond to applescript files the user has placed in my application support folder. when the user selects one of these menu items, i execute the appropriate script. i execute the script in a (sub) task (NSTask). i do it this way because i discovered (the hard/empirical way) that if an executing script, executes functionality in my app that calls -[NSScriptCommand suspendExecution], then the executing of that script will erroneously terminate early. using a sub task solves this problem. in my app, when i launch this task, i register for the NSTaskDidTerminateNotification and in my notification routine, i display any errors returned. this all works fine... except that as soon as i return from launching the sub task, the menu item (in the main menu bar) for the scripts menu un-highlights. i would like this to remain highlighted until my notification routine is called, in order to provide feedback to the user that his/her script is still executing. is this possible? if so, could someone provide any code and/or documentation pointers? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -[NSScriptCommand suspendExecution]
At 1:36 AM -0400 5/16/09, Jim Correia wrote: On Fri, May 15, 2009 at 12:26 PM, kvic...@pobox.com kvic...@pobox.com wrote: if i call -[NSScriptCommand suspendExecution] whilst execution a script command, i find that the executing script will still time out after 2 minutes. is this a bug in cocoa? or a misunderstanding on my part about suspendExecution? A misunderstanding on your part about how things work. jim, i was afraid that was the case. not the first time i've had a misunderstanding! :-) thanx for the reply, ken Even if you -suspendExecution and later return a result, the timeout that the sender specified when they sent the event - how long they were willing to wait for either an answer or a timeout error - is still in force. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
-[NSScriptCommand suspendExecution]
(note: i posted this to the applescript implementors list earlier this week, but i haven't received any replies. i'm reposting here in the hope that someone here may be able to help. my apologies if this is a violation of the rules.) if i call -[NSScriptCommand suspendExecution] whilst execution a script command, i find that the executing script will still time out after 2 minutes. is this a bug in cocoa? or a misunderstanding on my part about suspendExecution? thanx, ken p.s. for the record, my code seems to work fine and the subsequent, matching -[NSScriptCommand resumeExecutionWithResult:] works fine and returns the appropriate result. i'm just surprised that the script still times out even though i've suspended the command. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: converting a characer to a keycode
At 9:27 AM +0200 5/11/09, Jean-Daniel Dupas wrote: Le 9 mai 09 à 22:29, kvic...@pobox.com a écrit : At 9:14 PM -0700 5/8/09, glgue...@amug.org wrote: ken wrote: the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character. and while this is certainly doable, it feels awfully clumsy (and potentially slow). is there a better way? Create the inverse mapping once, e.g. in an NSDictionary, then use that mapping thereafter, instead of searching repeatedly. This assumes there is an unambiguous inverse mapping, which ain't necessarily so. For example, a keyboard with a numpad has duplicate key legends for all numpad keys. I think these numpad keys have different keycodes than the keys in the main alphanum layout. So given a character like 1 (or *, =, etc.) it's not possible to reverse it to a single unique keycode. greg, thanx for the reply. and yes i am aware of the possible duplicates. i was just hoping for a better way other that iterating via UCKeyTranslate (which turns out to be fast enough, so probably no need to cache via a dictionary or otherwise). An alternative would be to parse the UCHR resource yourself instead of using UCKeyTranslate. http://developer.apple.com/documentation/Carbon/reference/Unicode_Utilities_Ref/uu_app_uchr/uu_app_uchr.html i actually thought about doing that... but since it was easiest to just use UCKeyTranslate (i had pre-existing code i could easily copy, paste, modify) to get my surrounding code working, i went with that initially with the intent to explore other solutions if performance was an issue. performance wasn't/isn't an issue, so i've left the simple approach in. thanx for the suggestion. ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: converting a characer to a keycode
At 9:14 PM -0700 5/8/09, glgue...@amug.org wrote: ken wrote: the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character. and while this is certainly doable, it feels awfully clumsy (and potentially slow). is there a better way? Create the inverse mapping once, e.g. in an NSDictionary, then use that mapping thereafter, instead of searching repeatedly. This assumes there is an unambiguous inverse mapping, which ain't necessarily so. For example, a keyboard with a numpad has duplicate key legends for all numpad keys. I think these numpad keys have different keycodes than the keys in the main alphanum layout. So given a character like 1 (or *, =, etc.) it's not possible to reverse it to a single unique keycode. greg, thanx for the reply. and yes i am aware of the possible duplicates. i was just hoping for a better way other that iterating via UCKeyTranslate (which turns out to be fast enough, so probably no need to cache via a dictionary or otherwise). ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
converting a characer to a keycode
i would like to convert a character to its corresponding virtual keycode. the why: i allow users to specify keyboard equivalents for menu items (in a manner similar to xcode key binding preferences). for reasons i don't understand it works better use unshifted characters for the shifted numeric keys. ie, command-shift-1 works for me, whereas command-! (command-exclamation mark) does not. additonally, my app is fully scriptable and i allow the user to specify the keyboard shortcut via an applescript. thus, i would like to convert a script specification of command-exclamation mark to command-shift-1 (command-shift-one). the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character. and while this is certainly doable, it feels awfully clumsy (and potentially slow). is there a better way? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: virtual keycode to character
At 7:22 PM -0500 4/29/09, Ken Thomases wrote: On Apr 29, 2009, at 6:40 PM, kvic...@pobox.com wrote: thank you. this solved my problem. You're welcome. I'm glad I could help. and (i think) you've helped again. thanx. (see below) and for the archives (to help anyone in the future), here is my code: UInt32 deadKeyState = 0; UniCharCount actualCount = 0; UniChar baseChar; TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource(); CFDataRef keyLayoutPtr = (CFDataRef)TISGetInputSourceProperty( sourceRef, kTISPropertyUnicodeKeyLayoutData); CFRelease( sourceRef); UCKeyTranslate( (UCKeyboardLayout*)CFDataGetBytePtr(keyLayoutPtr), [theEvent keyCode], kUCKeyActionDown, 0, LMGetKbdLast(), Why LMGetKbdLast rather than LMGetKbdType? I think that the Last in LMGetKbdLast means former. That is, if the keyboard is switched at some point, then LMGetKbdType gives the current keyboard type and LMGetKbdLast gives the previous keyboard type. the documentation for LMGetKbdLast says: The last physical keyboard type used. i read that to mean the keyboard last used/typed on by the user, i.e., the keyboard used that triggered the current keyboard event. i'm assuming that you are correct and i've changed my code appropriately. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: virtual keycode to character
ken, thank you. this solved my problem. and for the archives (to help anyone in the future), here is my code: UInt32 deadKeyState = 0; UniCharCount actualCount = 0; UniChar baseChar; TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource(); CFDataRef keyLayoutPtr = (CFDataRef)TISGetInputSourceProperty( sourceRef, kTISPropertyUnicodeKeyLayoutData); CFRelease( sourceRef); UCKeyTranslate( (UCKeyboardLayout*)CFDataGetBytePtr(keyLayoutPtr), [theEvent keyCode], kUCKeyActionDown, 0, LMGetKbdLast(), kUCKeyTranslateNoDeadKeysBit, deadKeyState, 1, actualCount, baseChar); ken p.s. i realize this might have a bug if the unicode for the unmodified keyboard character is more than 1 unicharacter. At 9:53 PM -0500 4/27/09, Ken Thomases wrote: On Apr 27, 2009, at 7:46 PM, kvic...@pobox.com wrote: in my app, i allow the user to specify keyboard shortcuts for menu items (in a manner similar to xcode). for the string passed to -[MenuItem setKeyEquivalent], i pass the string obtained from the current event via [NSEvent charactersIgnoringModifiers]. this works fine almost all the time. however, for some keyboard presses it doesn't work properly, namely for shift and some of the number keys, eg., command-! (command exclamation mark) doesn't work as a keyboard equivalent, but shift-command-1 (shift command one) does work. thus, i would like a reliable way to go from virtual keycode to the non-shifted character. in searching the archives, this topic has come up several times, but all proposed solutions that i've found make use of one or more deprecated (in leopard) api calls. eg., LMGetKBDType or GetScriptManagerVariable, etc. does anyone have a solution that doesn't rely on any deprecated api calls? You can use TISCopyCurrentKeyboardLayoutInputSource to get the current keyboard input source. Then, you can query it using TISGetInputSourceProperty with kTISPropertyUnicodeKeyLayoutData to get the 'uchr' data for that keyboard layout. With that, you can call UCKeyTranslate. By the way, LMGetKbdType is not deprecated, at least according to its declaration in the headers. It is documented on a page which is, as a whole, marked as a legacy document. However, I don't know of a way to obtain the keyboard type otherwise (except in the context of a Carbon event). Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
virtual keycode to character
in my app, i allow the user to specify keyboard shortcuts for menu items (in a manner similar to xcode). for the string passed to -[MenuItem setKeyEquivalent], i pass the string obtained from the current event via [NSEvent charactersIgnoringModifiers]. this works fine almost all the time. however, for some keyboard presses it doesn't work properly, namely for shift and some of the number keys, eg., command-! (command exclamation mark) doesn't work as a keyboard equivalent, but shift-command-1 (shift command one) does work. thus, i would like a reliable way to go from virtual keycode to the non-shifted character. in searching the archives, this topic has come up several times, but all proposed solutions that i've found make use of one or more deprecated (in leopard) api calls. eg., LMGetKBDType or GetScriptManagerVariable, etc. does anyone have a solution that doesn't rely on any deprecated api calls? short of a better solution, i may just look at the keycode obtained from the event and check to see if it corresponds to one of the constants for number keys from Events.h. thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
printer name via NSPrintInfo after running Page Setup
after i run the page setup dialog (successfully), if i examine the name of the chosen printer (via [[printInfo printer] name]) should it reflect the printer chosen in the page setup dialog? i'm not seeing this. in fact, i am seeing the same printer name before and after running the page setup dialog. i'm not sure if this has to do with the printer's i have setup on my machine, or if this is a bug (in my code or one of the system frameworks). can anyone verify whether or not changing the printer in the page setup dialog should be reflected in the print info contained within the NSPageSetup sent to the page setup did complete method? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printer user friendly paper name to internal paper name?
daniel, thanx for the response. its not clear from the documentation whether or not the name specified for pageSizeForPaper is an internal name or a user name. in any case, i've solve my problem via methods i posted yesterday to this email list. ken At 10:56 AM +0200 4/20/09, Daniel Demiss wrote: Hi. I'm not quite sure if I got you right but: Am 17.04.2009 um 23:24 schrieb kvic...@pobox.com: my app is fully recordable and scriptable. when the user changes the page setup, i am able to successfully record it and indicate the paper name chosen via -[NSPrintInfo localizedPaperName]. How about saving the return value of paperName instead, which you could use in conjunction with NSPrinter's pageSizeForPaper:? Validation of the string would be as simple as NSZeroSize != [myPrinter pageSizeForPaper:userSuppliedPaperName] HTH Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printer user friendly paper name to internal paper name?
for the archives... i received the following off-list and it is exactly what i was looking for. Just an idea, why not use: PMPrinterGetPaperList and then loop through them all and compare what you have to: PMPaperCreateLocalizedName you can get the PMPrinter from: PMSessionGetCurrentPrinter which you can get from -[NSPrintInfo PMPrintSession] At 2:24 PM -0700 4/17/09, kvic...@pobox.com wrote: my app is fully recordable and scriptable. when the user changes the page setup, i am able to successfully record it and indicate the paper name chosen via -[NSPrintInfo localizedPaperName]. however, if the user attemps to write a script (either directly or by modifying a previously recorded script), i need to validate any paper name the user has specified. i don't see how to go from a user specified paper name to an internal name such that i can call -[NSPrintInfo setPaperName:]. have i missed something? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
printer user friendly paper name to internal paper name?
my app is fully recordable and scriptable. when the user changes the page setup, i am able to successfully record it and indicate the paper name chosen via -[NSPrintInfo localizedPaperName]. however, if the user attemps to write a script (either directly or by modifying a previously recorded script), i need to validate any paper name the user has specified. i don't see how to go from a user specified paper name to an internal name such that i can call -[NSPrintInfo setPaperName:]. have i missed something? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
archiving NSPrintInfo created via initWithDictionary crashes
on 10.5.6 the following code snippet: NSPrintInfo* sp = [NSPrintInfo sharedPrintInfo]; NSDictionary* dict = [sp dictionary]; NSPrintInfo* pi = [[NSPrintInfo alloc] initWithDictionary: dict]; NSData* piData = [NSKeyedArchiver archivedDataWithRootObject: pi]; will crash with the following: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs' with the call stack: #0 0x96772fb4 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ #1 0x96051e3b in objc_exception_throw #2 0x96772eeb in +[NSException raise:format:arguments:] #3 0x96772f2a in +[NSException raise:format:] #4 0x9689935e in -[NSKeyedArchiver encodeValueOfObjCType:at:] #5 0x96969a71 in -[NSValue encodeWithCoder:] #6 0x967e6d2d in _encodeObject #7 0x9685742d in -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] #8 0x96806146 in -[NSDictionary(NSDictionary) encodeWithCoder:] #9 0x967e6d2d in _encodeObject #10 0x946caa14 in -[NSPrintInfo encodeWithCoder:] #11 0x967e6d2d in _encodeObject #12 0x967e64a8 in +[NSKeyedArchiver archivedDataWithRootObject:] #13 0x1f3e in main at main.m:19 however, the following doesn't crash: NSPrintInfo* sp = [NSPrintInfo sharedPrintInfo]; NSDictionary* dict = [sp dictionary]; NSPrintInfo* pi = [[NSPrintInfo alloc] initWithDictionary: dict]; [pi description]; NSData* piData = [NSKeyedArchiver archivedDataWithRootObject: pi]; filed as radar #: 6656704 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
multiple NSTextFields and undo problem
i've got a window that has several editable NSTextFields (and other controls and views). if i do some editting in one of the fields and then select another field (tab or click another text field), as you can see in the below stack trace, this results in a call to -[NSUndoManager removeAllActions]. as i often have other undo actions for this window, and i use one undo manager for all activity for this window, this is destroying my undo stack! it seems to me that instead of calling removeAllActions while a text view resigns FirstResponder, it should instead be calling -[NSUndoManager removeAllActionsWithTarget:]. #0 0x93389675 in -[NSUndoManager removeAllActions] #1 0x906112e9 in syncTextWithTextView #2 0x904b1b2c in -[NSActionCell setObjectValue:] #3 0x904b1653 in -[NSCell setStringValue:] #4 0x90633353 in -[NSTextField textDidEndEditing:] #5 0x93320e1a in _nsnote_callback #6 0x970e98da in __CFXNotificationPost #7 0x970e9bb3 in _CFXNotificationPostNotification #8 0x9331e080 in -[NSNotificationCenter postNotificationName:object:userInfo:] #9 0x90632b93 in -[NSTextView(NSSharing) resignFirstResponder] #10 0x905a8b0d in -[NSWindow makeFirstResponder:] my original code for this window goes back to early 2006 and this (destroying the undo stack) wasn't happening then. unfortunately, i haven't fully exercised this code, with undo, since then, so i don't know when the change/bug was introduced. i've filed bug id# 6589070 for this. in the meantime, can anyone recommend a work around? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSCaledarDate's deprecation
At Thu, 22 Jan 2009 23:13:45 +, Benjamin Dobson wrote: On 22 Jan 2009, at 22:52:56, kvic...@pobox.com wrote: in anticipation of the deprecation of NSCaledarDate, i am in the process of converting my app to use NSDate and friends. and while the process is mostly straightforward and not all that difficult, it is tedious. when i think i'm done, i'd like to be able to do a fresh build and if possible have the compiler tell me any places i might have missed... these would be places where i used a method of NSCalendarDate that i missed with all my text searches. is there anyway to get the compiler to do this for me? If you delete all occurrences of NSCalendarDate and what relevant code you can see, the compiler will pick up on undefined variables. i'm not concerned with lagging instances of the text NSCalendarDate as i'm pretty sure i can find and fix all of them. i am concerned with missing a call to a method of NSCalendarDate. if this were a class of my own, then i would simply remove the .h/.m files from my project and the compiler would then tell me of any erroneous calls. but i can't do that with cocoa files/classes. and since NSCalendarDate is a subclass of NSDate, using an NSCalendarDate method on an NSDate object is perfectly legal at compile time. and this is what i'd like to catch at compile time, especially if i have (erroneously) cast an NSDate object to id in the past. ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSCaledarDate's deprecation
At 6:39 PM -0500 1/23/09, Andy Lee wrote: On Jan 23, 2009, at 2:45 PM, kvic...@pobox.com wrote: At Thu, 22 Jan 2009 23:13:45 +, Benjamin Dobson wrote: On 22 Jan 2009, at 22:52:56, kvic...@pobox.com wrote: in anticipation of the deprecation of NSCaledarDate, i am in the process of converting my app to use NSDate and friends. and while the process is mostly straightforward and not all that difficult, it is tedious. when i think i'm done, i'd like to be able to do a fresh build and if possible have the compiler tell me any places i might have missed... these would be places where i used a method of NSCalendarDate that i missed with all my text searches. is there anyway to get the compiler to do this for me? If you delete all occurrences of NSCalendarDate and what relevant code you can see, the compiler will pick up on undefined variables. i'm not concerned with lagging instances of the text NSCalendarDate as i'm pretty sure i can find and fix all of them. i am concerned with missing a call to a method of NSCalendarDate. if this were a class of my own, then i would simply remove the .h/.m files from my project and the compiler would then tell me of any erroneous calls. but i can't do that with cocoa files/classes. and since NSCalendarDate is a subclass of NSDate, using an NSCalendarDate method on an NSDate object is perfectly legal at compile time. and this is what i'd like to catch at compile time, especially if i have (erroneously) cast an NSDate object to id in the past. Once you cast to id all bets are off. Maybe you could try a hack like temporarily removing NSCalendarDate.h, but even then there are other places where the compiler can't help you, like key paths and @selector(). I think if you want to be really, really sure you're going to have to grep your code for each of the 20 or so method names that are specific to NSCalendarDate and not NSDate. Maybe you could write a script to do it. --Andy thats what i suspected. thanx for the reply, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSCaledarDate's deprecation
in anticipation of the deprecation of NSCaledarDate, i am in the process of converting my app to use NSDate and friends. and while the process is mostly straightforward and not all that difficult, it is tedious. when i think i'm done, i'd like to be able to do a fresh build and if possible have the compiler tell me any places i might have missed... these would be places where i used a method of NSCalendarDate that i missed with all my text searches. is there anyway to get the compiler to do this for me? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTreeController delete slowness...
this if primarily for the archives, but its not a complete solution. i've managed to improve the performance of deletes by a factor of 4-4.5 by simply calling: -[NSTreeController setSelectionIndexPaths: nil]; prior to actually removing objects from my bound set. note that this is still a little on the slow side (about .4 seconds to delete 603 of 610 top level objects in an outline view), but its sorta acceptable. ken At 3:50 PM -0800 1/1/09, kvic...@pobox.com wrote: i received the following advice off-list: IIRC, when you do set operations like that, it performs a remove for each item. Try making a mutable copy of the content set, performing the set operation, and then setting the content of the controller with the new set. That should wind up being faster as only one KVO notification will be sent rather than 600. so i tried this. and while setting the content of the treecontroller directly did save a few milliseconds (of ~ 1.8 seconds), it did NOT update the mutable set the treecontroller is bound to. i also tried getting a mutable copy of the set the treecontroller is bound to, removing the deleted objects from this set, and then (re)setting the iVar holding the bound set. and this again saved on a few milliseconds (of the ~ 1.8 seconds). i've also tried unbinding the tree controller, deleting the objects from my iVar set, and re-establishing the treecontroller's binding. again, this only makes a difference of a few milliseconds (of the ~ 1.8 seconds). it still doesn't feel right to me that it should take ~1.8 seconds to delete 603 top level objects from an outline that contains 610 top level objects. (fwiw, those 603 top level objects contain 1344 second level objects out of a total of 1399 total second level objects). i'm still hopeful someone can suggest something that will reduce this time to something reasonable and/or suggest something i should try. thanx, ken At 2:21 PM -0800 12/30/08, kvic...@pobox.com wrote: i've got an NSOutlineView bound via an NSTreeController to a mutable set in my model. in the sample i've been exploring, my outline consists of 608 top level items in the outline, and only goes one level deep. each top level item has 2 or more children, and there are a total of 1393 children. deletion can only happen for the top level objects, and when the user deletes one or more of my items, i create a set of the objects to be deleted and the call: [myController removeProxySet: topLevelObjects]; the code for removeProxySet is: - (void) removeProxySet: (NSSet*) inSet { [[self proxySet] minusSet: inSet]; } where proxySet is simply the iVar mutable set in my controller that has my model objects. this all works fine and when the user asks to delete one or more top level items, they appropriately disappear from the outline view. however, it is rather slow! when i looked at this with Shark, deleting just 2 of the top level items spent 750 ms in [NSTreeController setContent], which is called from Foundation NSKVOMinusSetAndNotify (in response to my call of minusSet). if i delete ~600 of the top level items, it takes 1.9 seconds! there are obviously some calls to some of my code to access values for the various columns of the outline view, but the overwhelming majority of the time is spent in app kit and foundation code, mostly in tree controller and friends. this is on a 3GHz MacPro with 6G of memory and a total of 4 cores. i don't believe the disk is being hit for any of this. (fwiw, i obtained my numbers by putting shark into remote mode and simply starting and stopping it when deleting my items.) this seems unreasonably slow to me. i realize that i'm not posting very much code, but since so little of my code seems to be involved in the slowness, i didn't think it really relevant. should i be doing something other than removeProxySet and minusSet? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTreeController delete slowness...
i received the following advice off-list: IIRC, when you do set operations like that, it performs a remove for each item. Try making a mutable copy of the content set, performing the set operation, and then setting the content of the controller with the new set. That should wind up being faster as only one KVO notification will be sent rather than 600. so i tried this. and while setting the content of the treecontroller directly did save a few milliseconds (of ~ 1.8 seconds), it did NOT update the mutable set the treecontroller is bound to. i also tried getting a mutable copy of the set the treecontroller is bound to, removing the deleted objects from this set, and then (re)setting the iVar holding the bound set. and this again saved on a few milliseconds (of the ~ 1.8 seconds). i've also tried unbinding the tree controller, deleting the objects from my iVar set, and re-establishing the treecontroller's binding. again, this only makes a difference of a few milliseconds (of the ~ 1.8 seconds). it still doesn't feel right to me that it should take ~1.8 seconds to delete 603 top level objects from an outline that contains 610 top level objects. (fwiw, those 603 top level objects contain 1344 second level objects out of a total of 1399 total second level objects). i'm still hopeful someone can suggest something that will reduce this time to something reasonable and/or suggest something i should try. thanx, ken At 2:21 PM -0800 12/30/08, kvic...@pobox.com wrote: i've got an NSOutlineView bound via an NSTreeController to a mutable set in my model. in the sample i've been exploring, my outline consists of 608 top level items in the outline, and only goes one level deep. each top level item has 2 or more children, and there are a total of 1393 children. deletion can only happen for the top level objects, and when the user deletes one or more of my items, i create a set of the objects to be deleted and the call: [myController removeProxySet: topLevelObjects]; the code for removeProxySet is: - (void) removeProxySet: (NSSet*) inSet { [[self proxySet] minusSet: inSet]; } where proxySet is simply the iVar mutable set in my controller that has my model objects. this all works fine and when the user asks to delete one or more top level items, they appropriately disappear from the outline view. however, it is rather slow! when i looked at this with Shark, deleting just 2 of the top level items spent 750 ms in [NSTreeController setContent], which is called from Foundation NSKVOMinusSetAndNotify (in response to my call of minusSet). if i delete ~600 of the top level items, it takes 1.9 seconds! there are obviously some calls to some of my code to access values for the various columns of the outline view, but the overwhelming majority of the time is spent in app kit and foundation code, mostly in tree controller and friends. this is on a 3GHz MacPro with 6G of memory and a total of 4 cores. i don't believe the disk is being hit for any of this. (fwiw, i obtained my numbers by putting shark into remote mode and simply starting and stopping it when deleting my items.) this seems unreasonably slow to me. i realize that i'm not posting very much code, but since so little of my code seems to be involved in the slowness, i didn't think it really relevant. should i be doing something other than removeProxySet and minusSet? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTreeController delete slowness...
i've got an NSOutlineView bound via an NSTreeController to a mutable set in my model. in the sample i've been exploring, my outline consists of 608 top level items in the outline, and only goes one level deep. each top level item has 2 or more children, and there are a total of 1393 children. deletion can only happen for the top level objects, and when the user deletes one or more of my items, i create a set of the objects to be deleted and the call: [myController removeProxySet: topLevelObjects]; the code for removeProxySet is: - (void) removeProxySet: (NSSet*) inSet { [[self proxySet] minusSet: inSet]; } where proxySet is simply the iVar mutable set in my controller that has my model objects. this all works fine and when the user asks to delete one or more top level items, they appropriately disappear from the outline view. however, it is rather slow! when i looked at this with Shark, deleting just 2 of the top level items spent 750 ms in [NSTreeController setContent], which is called from Foundation NSKVOMinusSetAndNotify (in response to my call of minusSet). if i delete ~600 of the top level items, it takes 1.9 seconds! there are obviously some calls to some of my code to access values for the various columns of the outline view, but the overwhelming majority of the time is spent in app kit and foundation code, mostly in tree controller and friends. this is on a 3GHz MacPro with 6G of memory and a total of 4 cores. i don't believe the disk is being hit for any of this. (fwiw, i obtained my numbers by putting shark into remote mode and simply starting and stopping it when deleting my items.) this seems unreasonably slow to me. i realize that i'm not posting very much code, but since so little of my code seems to be involved in the slowness, i didn't think it really relevant. should i be doing something other than removeProxySet and minusSet? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
problems debugging cocoa app w/ gdb
for sometime now (i don't remember when this started, possibly w/ leopard or 10.5.5 or the previous dev tools update), i've been getting a number of lines like the following on the debugger console when hitting breakpoints: warning: Trying to look up NSString in 'this' but 'this' is not an aggregate warning: Trying to look up description in 'this' but 'this' is not an aggregate warning: Trying to look up void in 'this' but 'this' is not an aggregate warning: Trying to look up _pbxgdb_objc_dynamic_type in 'this' but 'this' is not an aggregate warning: Trying to look up _pbxgdb_objc_compute_super_class_list in 'this' but 'this' is not an aggregate warning: Trying to look up _pbxgdb_cf_introspect_string in 'this' but 'this' is not an aggregate additionally, the variables pane of the debugger window (the top right pane) will show incomplete type as the value of many of my variables, usually scaler type (e.g., int, BOOL) or variables declared as: id. i've been working around this via assorted NSLog statements, but its getting really old. a clean build did not make the problem go away. i'm using 10.5.5 and objective-c++ and the latest release xcode tools. can anyone suggest how to fix this? thanx, ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]