I'm working on a block styler dialog with a "file selection with browse" block. My intention is to allow the user to select an existing text file or key in a name for a new file, select some objects, then write the info to the file when OK is pressed. However, if a new file name is keyed in, an error message pops up saying that the file doesn't exist. This isn't really a problem for me, as it will be created later. The error won't let you continue and I see no option for turning off this validation. How can I use the file browse block to allow the user to key in a path for a new file to be created later?
Unfortunately, that is a (frustrating) limitation of the file selection block. Please file an ER to have this behavior changed.
The only workaround I know of using block styler is to use a Folder Selection with Browse block in conjunction with a string block. The user selects the folder with the folder selection block, then types in the name of the file in the string block. You code combines the two to produce a filename. You would also have to manually validate for disallowed characters, etc.
You could also pop-up a separate file selector with an action button using tools in your programming language (i.e. System.Windows.Forms in .NET; Tk in Python, etc.)
Inside the callback for an action button you could use the wrapper for UF_UI_create_filebox():
UFUi.CreateFileboxData createFilebox(String promptString, String titleString, String filterString, String defaultName) throws NXException, RemoteException
This handles non-existing files OK. I ususally style the button with a 'open file' bitmap.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: NX126.96.36.199 MP11 64bit Testing: NX188.8.131.52