When saving a file there is usually a pre-selected file name given in the dialogue… such as for a markdown file it is "untitled.markdown". The whole filename is selected… but is it possible to actually get only the "untitled" part selected?
thx,
Dan
On 6. Nov 2006, at 12:55, Daniel Käsmayr wrote:
When saving a file there is usually a pre-selected file name given in the dialogue… such as for a markdown file it is "untitled.markdown". The whole filename is selected… but is it possible to actually get only the "untitled" part selected?
Not really -- it’s a system dialog, and the normal way to improve the user experience here, is to not show the extension at all, but I found that too abstract for a program which is used with hundreds of different extensions.
Allan,
OK, thanks for the quick reply. And a good call on usability on your side!
Dan
On 11/6/06 4:29 AM, in article AE0E3EEF-7BBC-41D3-A333-1E348D6D9934@macromates.com, "Allan Odgaard" throw-away-1@macromates.com wrote:
On 6. Nov 2006, at 12:55, Daniel Käsmayr wrote:
When saving a file there is usually a pre-selected file name given in the dialogue such as for a markdown file it is "untitled.markdown". The whole filename is selected but is it possible to actually get only the "untitled" part selected?
Not really -- it¹s a system dialog, and the normal way to improve the user experience here, is to not show the extension at all, but I found that too abstract for a program which is used with hundreds of different extensions.
Not really. It's quite easy to select just the filename part:
NSTextView* fe = (NSTextView*)[theSavePanel firstResponder]; NSString* f = [[fe textStorage] string]; f = [f stringByDeletingPathExtension]; [fe setSelectedRange: NSMakeRange(0, [f length])];
For an example of an app that does this, look at Amadeus II. It's very welcome behavior. m.
On 9. Nov 2006, at 16:37, Matt Neuburg wrote:
Not really -- it’s a system dialog [...]
Not really. It's quite easy to select just the filename part:
NSTextView* fe = (NSTextView*)[theSavePanel firstResponder]; NSString* f = [[fe textStorage] string]; f = [f stringByDeletingPathExtension]; [fe setSelectedRange: NSMakeRange(0, [f length])];
Thanks, but when do you call this code?
Here is what I presently have:
NSSavePanel* savePanel = [NSSavePanel savePanel]; [savePanel setAccessoryView:encodingView]; [savePanel setTreatsFilePackagesAsDirectories:YES]; [savePanel beginSheetForDirectory:[aPath stringByDeletingLastPathComponent] file:([aPath lastPathComponent] ?: @"untitled") modalForWindow:[self window] modalDelegate:self didEndSelector:@selector (savePanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
Prior to calling beginSheetForDirectory:… there is no first responder in the panel, nor does the panel show the filename yet.
On 11/9/06 8:54 AM, in article 4B7DE41E-932A-4263-AE89-B123B6EEAF9E@macromates.com, "Allan Odgaard" throw-away-1@macromates.com wrote:
On 9. Nov 2006, at 16:37, Matt Neuburg wrote:
Not really -- it¹s a system dialog [...]
Not really. It's quite easy to select just the filename part:
NSTextView* fe = (NSTextView*)[theSavePanel firstResponder]; NSString* f = [[fe textStorage] string]; f = [f stringByDeletingPathExtension]; [fe setSelectedRange: NSMakeRange(0, [f length])];
Thanks, but when do you call this code?
Here is what I presently have:
NSSavePanel* savePanel = [NSSavePanel savePanel]; [savePanel setAccessoryView:encodingView]; [savePanel setTreatsFilePackagesAsDirectories:YES]; [savePanel beginSheetForDirectory:[aPath
stringByDeletingLastPathComponent] file:([aPath lastPathComponent] ?: @"untitled") modalForWindow:[self window] modalDelegate:self didEndSelector:@selector (savePanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
Prior to calling beginSheetForDirectory: there is no first responder in the panel, nor does the panel show the filename yet.
Obviously, I call my code after your code. m.
On 10. Nov 2006, at 16:47, Matt Neuburg wrote:
[...] Prior to calling beginSheetForDirectory:… there is no first responder in the panel, nor does the panel show the filename yet.
Obviously, I call my code after your code. m.
For some reason I had in my mind that beginSheetForDirectory:… would start a local event loop, which it clearly doesn’t -- thanks, I’ll add your code (with a doesRespondToSelector: check) to TM.