Product Documentation
Cadence User Interface SKILL Reference
Product Version IC23.1, September 2023

hiCreateFileSelectorField

hiCreateFileSelectorField(
?name s_fieldName 
?mode s_mode
[ ?prompt t_prompt ] 
[ ?value t_currentValue ]
[ ?defValue t_defaultValue ] 
[ ?callback g_callback ]
[ ?modifyCallback g_modifyCallback ]
[ ?focusInCallback g_focusInCallback ]
[ ?editable g_editable ]
[ ?enabled g_enabled ]
[ ?invisible g_invisible ]
[ ?nextField g_nextField ]
[ ?confirmOverwrite g_confirmOverwrite ]
) 
=> r_fieldHandle

Description

Creates a type-in field similar to a string field, except that it also has a Browse button at the right of the type-in box. The Browse button, when pressed, brings up a file dialog box that lets users select a file or directory. You can use the ?mode argument to specify what the user is allowed to select. The file dialog is modal, that is, it blocks access to the application while it is open. When the user makes a selection and closes the file dialog, the selection is entered into the type-in box.

This function uses the hiDisplayFileDialog function to create the file dialog.

The file selector field can also have a context menu, that is, a pop-up menu that is displayed when you right-click on the field.

For information on creating tooltips for fields, see Creating Tool Tips for Fields.

Arguments

?name s_fieldName

Handle to this field within a form. To reference it, use:

formHandle->hiFieldSym

?mode s_mode

Symbol specifying what the user is allowed to select in the file dialog box. This value is passed to hiDisplayFileDialog. Legal values are:

  • ’anyFile: Any file, whether it exists or not. This option is typically used for "Save As" dialog boxes.
  • ’existingFile: An existing file.This option is typically used for Open File dialog boxes.
  • ’existingFiles: zero or more existing file. This option is typically used for Open File dialog boxes.
  • ’directory: The file dialog displays both files and directories.
  • ’directoryOnly: The file dialog displays only directories.

The default value is ’existingFile.

?prompt t_prompt

String specifying the prompt for the field. To reference it, use:

formHandle->hiFieldSym->prompt

?value t_currentValue

  

Initial and current value of this field. To reference it, use:

formHandle->hiFieldSym->value

?defValue t_defaultValue

  

Displays the default value of the field. This value is equal to the initial entry in ?value if ?defaultValue is not specified. To reference the value, use:

formHandle->hiFieldSym->defValue

?callback g_callback

  

A callback of string, symbol, or function object type. For type-in fields, the callback is called when the field "loses focus” (when the cursor leaves the form, the user tabs to another field, and so forth) or when the user selects any button in the form. If you want a callback that is called when the field comes into focus, use the g_focusInCallback argument.

If the callback is of string type, you can specify one or more SKILL functions or even multiple SKILL statements that should be executed when the value of the field changes.

?modifyCallback g_modifyCallback

  

SKILL function to be executed whenever any change is made in the text field, for example, by typing a value. The modify callback is called when a change is detected in the field but before the change is displayed. The callback can be of string, symbol, or function object type.

A modify callback of symbol or function object type is passed following arguments:

< field modify callback > ( o_field g_scope t_latestTextValue g_sourceOfChange)

, where o_field is the field whose modify callback is triggered, g_scope is where the field is instantiated, t_latestTextValue is the latest text value of the field, and g_sourceOfChange is t or nil, t indicates that the change was made through the program (by changing the value of the field) and nil indicates that the change was made by a user action.

The modify callback of string type is passed the following arguments:

s_fieldName t_latestTextValue g_sourceOfChange

where s_fieldName is the symbol of the field in which the change was made, t_latestTextValue is the latest text value of the field, and g_sourceOfChange is t or nil where t indicates that the change was made programmatically (by changing the value of the field) and nil indicates that the change was made by a user action.

The modify callback function should return the following:

t | nil | value

If the modify callback function returns t, the changes made to the field are allowed and are displayed as they are entered. If the function returns nil, the changes made to the field are not allowed and are not displayed—the original value of the field is retained. If the function returns some other value, it must be a string. This value replaces the current value of the field.

?focusInCallback g_focusInCallback

  

SKILL function to be executed whenever the field comes into focus.

?editable g_editable

  

Makes the field editable, nil to make it read-only.

?enabled g_enabled

  

Specifies whether the fields in the layout are enabled. The default value is t.

?invisible g_invisible

  

Specifies whether the layout and the fields within are invisible. The default value is nil.

?nextField g_nextField

  

Symbol or string indicating the next field to bring into focus when the Tab key is pressed. If you specify nil or do not specify this argument, the Tab traversal order is determined by the tabOrderIsAddOrder argument of hiCreateAppForm or hiCreateScrollRegion. If the tabOrderIsAddOrder argument is not set or if its value is nil, the default traversal order is based on the form layout —left-to-right and top-to-bottom— beginning with the field at the top-left corner of the form.

?confirmOverwrite g_confirmOverwrite

Specifies whether confirmation dialog is needed when overwriting an existing file. The default value is t.

Values Returned

r_fieldHandle

Handle to the file selector field.

Examples

(setq workDir (prependInstallPath "test"))
(setq myField (hiCreateFileSelectorField
?name ’myField
?mode ’existingFile
?prompt "File Name"
?value (strcat workDir "/*.il")
?defValue (strcat workDir "/myCode.il")))
(putprop myField "Choose a Script" ’hiFileDialogCaption)
(putprop myField "myCode.il" ’hiFileDialogDefaultValue)
(putprop myField "SKILL Script (*.il);;All Files (*)" ’hiFileDialogFilter)
(putprop myField workDir ’hiFileDialogWorkingDir)

Additional Information

You can set the following properties on the file selector field to specify attributes for the file dialog box:

Property Name Type Default Value

hiFileDialogCaption

String

"Choose a File" or "Choose a Directory"

hiFileDialogDefaultValue

String

""

hiFileDialogFilter

String

""

hiFileDialogWorkingDir

String

"."

hiFileDialogMode

Symbol

’existingFile

hiFileDialogCallback

String

""

hiFileDialogUserData

Symbol

’_hiNoData

hiSimplifyFilename

t|nil

nil

hiDontResolveLinks

t|nil

nil

The first seven properties correspond to the arguments used for creating a file dialog box with hiDisplayFileDialog and are passed to hiDisplayFileDialog. If hiSimplifyFilename is set to t, the path of the file or directory selected in the file dialog box is expanded to an absolute (full) path before it is displayed in the type-in field. If hiDontResolveLinks is set to t, links in the path are not resolved when the path is being expanded to an absolute path.

For example, to put properties on a file selector field called myField, do the following:

myField->hiFileDialogCaption="Choose a Script"
myField->hiFileDialogDefaultValue="myCode.il"
myField->hiFileDialogFilter= "SKILL Script (*.il);;All Files (*)"
myField->hiFileDialogWorkingDir="/usr1"
myField->hiFileDialogMode=’anyFile
myField->hiSimplifyFilename=t
myField->hiDontResolveLinks=nil

The file selector field does not have special formats like the string field.

Related Topics

Form and Field Functions

hiDisplayFileDialog

hiCreateStringField


Return to top
 ⠀
X