hiCreateMLTextField
hiCreateMLTextField(?names_fieldName[?promptt_prompt] [?valuet_value] [?helpg_fieldHelp] [?defValuet_defaultValue] [?fontt_font] [?hasVerticalScrollbarg_hasVerticalScrollbar] [?hasHorizontalScrollbarg_hasHorizontalScrollbar] [?enableWordWrapg_enableWordWrap] [?editableg_editable] [?enabledg_enabled] [?invisibleg_invisible] [?callbackg_callback] [?focusInCallbackg_focusInCallback] [?changeCBg_changeCB] [?nextFieldg_nextField] ) =>r_fieldHandle
Description
Creates a multiline text field entry for a form. Any input typed into this field gets converted to a single string accessible through SKILL.
To select the proper size and location of the multiline text field in a form, first select a specific size range for the field, and then use the hiGetTextFieldFit function to find out the pixel size it needs for the specified range.
To create a new line in a multiline text field, the user has to press either Control-Return or Shift-Return. Pressing just the Return key applies the changes indicated in the form. To move to the next tab stop, the user has to press Control-Tab. Pressing just the Tab key moves the cursor to the next field in the form.
This 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
Value Returned
Examples
The following sample uses a multiline text field to display the contents of a given file.
procedure( trMoreFile( )
let( ( fileNameField fileContentsField theForm )
;;; creating the File Name string field
fileNameField = hiCreateStringField(
?name 'trFileNameField
?prompt "File Name"
?defValue ".cshrc"
?callback "trMoreFileCB( hiGetCurrentForm() 'trFileNameField )"
)
;;; creating the Contents multiline text field for
;;; viewing the file
fileContentsField = hiCreateMLTextField(
?name 'trMLTextField
?prompt "Contents"
?defValue ""
?editable t ;; so users can edit the file
)
;;; creating the form theForm = hiCreateAppForm(
?name gensym( 'trMoreFile )
?formTitle "File Browser"
?callback "trMoreFileCB(hiGetCurrentForm() 'apply)"
?buttonLayout 'ApplyCancelDef
?fields
list( fileNameField fileContentsField )
)
hiDisplayForm( theForm )
) ; let
) ; procedure
procedure( trMoreFileCB( theForm actionOrField ) case( actionOrField
;;; checking if the file exists
( trFileNameField
if( isFile( theForm->trFileNameField->value )
then
println("File exists")
t
else
println("File Does Not Exist--Try Again")
nil
) ;if
)
( apply
when( trMoreFileCB( theForm 'trFileNameField )
theForm->trMLTextField->value =
trReadFileIntoString(
theForm->trFileNameField->value )
) ; when
)
( t
error( "Illegal action or unknown field: %L" actionOrField )
)
) ; case
) ; procedure
;;; The following procedure returns a list of the lines ;;; in the file in the correct order procedure( trReadFile( pathname ) let( ( inPort nextLine allLines )
inPort = infile( pathname )
when( inPort = infile( pathname )
while( gets( nextLine inPort )
allLines = cons( nextLine allLines )
); while
close( inPort )
) ; when
reverse( allLines )
) ; let
) ; procedure
;;; reading the entire file into a single string procedure( trReadFileIntoString( pathname ) let( ( allLines )
allLines = trReadFile( pathname )
when( allLines apply( 'strcat allLines ) )
) ; let
) ; procedure
trMoreFile
After the file browser is displayed, type the name of an existing file and press Apply to view the file.
Related Topics
Creating Context Menus for Fields
Return to top