Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you "preselect" a file in the NSOpenPanel dialog

Does anyone know how to preselect a file in the NSOpenPanel dialog?

This has been asked several times before, but none of those questions were answered with a working solution. Setting nameFieldStringValue has no effect as the open dialog does not have a textfield for the user to type in a name. Setting the directoryURL only sets the current directory in the dialog.

like image 729
hvanbrug Avatar asked Sep 19 '13 20:09

hvanbrug


1 Answers

Try like this:-

NSOpenPanel *op=[NSOpenPanel openPanel];
[op setDirectoryURL:[NSURL URLWithString:@"file://localhost/Users/Home/Desktop/yourfile.sh/"]];
[op runModal];
like image 149
Hussain Shabbir Avatar answered Oct 21 '22 19:10

Hussain Shabbir