




The text in the pane.
The position of the caret in the text (from 0).
The maximum number of characters allowed.
Controls the enabled state of the pane.
A function called to complete the text.
The type of arguments to callback .
A function usually called when the user presses 
Return
.
The type of arguments to callback .
A function called when a change is made.
A function called to validate a change. Note: Implemented for Motif only, not Microsoft Windows or Mac OS X.
A function called when certain keyboard gestures occur in the pane.
text-input-pane-text
text-input-pane-max-characters
text-input-pane-completion-function
text-input-pane-callback
text-input-pane-confirm-change-function
text-input-pane-change-callback
text-input-pane-navigation-callback
text-input-pane-editing-callback
text-input-pane-enabled
text-input-pane-buttons-enabled
The class 
text-input-pane
 provides a great deal of flexibility in its handling of the text being entered. It starts with the initial text and caret-position specified by the arguments 
text
 and 
caret-position
 respectively. It limits the number of characters entered with the 
max-characters
 argument (which defaults to 
nil
, meaning there is no maximum). 
If 
enabled
 is 
nil
, the pane is disabled. If 
enabled
 is 
:read-only
, then the pane shows the text and allows it to be selected without it being editable. In this case the visual appearance varies between window systems, but often the text can be copied and the caret position altered. If 
enabled
 is any other true value, then the pane is fully enabled. The default value of 
enabled
 is 
t
.
A 
completion-function
 can be specified which will get called when the completion gesture is made by the user (or pressing the 
Tab
 key) or when text-input-pane-complete-text is called. The 
completion-function
 is called with the pane and the text to complete and should return either 
nil
, the completed text or a list of candidate completions. In the latter case, the CAPI will prompt the user for the completion they wish, and this will become the new text.
callback
, if non-
nil
, is called when the user presses 
Return
, unless 
navigation-callback
 is non-
nil
, in which case 
navigation-callback
 is called instead.
When the text or caret-position is changed, the callback change-callback is called with the text , the pane itself, the interface and the caret-position . The arguments that are passed to the change-callback can be altered by specifying the change-callback-type (see the callbacks class for details of possible values).
Note: the change-callback is potentially called more than once for each user gesture.
With the Motif implementation it is possible to check changes that the user makes to the 
text-input-pane
 by providing a 
confirm-change-function
 which gets passed the new	 text, the pane itself, its interface and the new caret position, and which should return non-
nil
 if it is OK to make the change. If 
nil
 is returned, then the pane will be unaltered and a beep will be signalled to indicate that the new values were invalid.
navigation-callback
, if non-
nil
, is a function that will be called when certain navigation gestures are used in the 
text-input-pane
. The function is called with two arguments, the pane itself, and one of the following keywords:
Tab Backwards
 (usually 
Shift+Tab
)  was pressed.
Return
 was pressed.
Shift+Return
 was pressed.
Enter
 was pressed.
Note: 
Enter
 is the key usually found on the numeric keypad.
When 
navigation-callback
 is non-
nil
, it is called instead of 
callback
 when 
Return
 is pressed. 
callback
 is still called via an OK button if there is one (see 
buttons
 below).
navigation-callback is implemented only on Microsoft Windows and Cocoa.
editing-callback
, if non-
nil
, is a function of two arguments:
pane
 is the 
text-input-pane
 and 
type
 is a keyword. 
editing-callback
 is called with 
type
 
:start
 when the user starts editing and 
type
 
:end
 when the user stops editing. In general, this occurs when the focus changes, but on Cocoa 
type
 
:start
 is passed when the first change is made to the text.
buttons specifies toolbar buttons which appear next to the pane and facilitate user actions on it. It also specifies the position of the buttons relative to the pane. This feature appears in the Common LispWorks IDE, for example the Class box of the Class Browser.
The allowed keys and values of the plist buttons are:
A boolean or a plist, default value 
t
. If true, a button which calls 
callback
 appears. If the  value is a plist then this plist supplies details for the button, as described below.
A boolean or a plist, default value 
nil
. If true, a button which calls 
cancel-function
 appears. A plist value is interpreted as for 
:ok
  and can also contain the key 
:accelerator
 which specifies an accelerator used for the button. There is no default accelerator.
A boolean or a plist. If true, a button which calls 
completion-function
 appears. The default value is 
t
 if 
completion-function
 is non-
nil
, and 
nil
 otherwise. A plist value is interpreted as for 
:ok
.
A keyword or a plist. If true, a button which invokes prompt-for-file appears. If the value is 
:save
 or 
:open
 then it is passed as the operation argument to prompt-for-file, replacing the text in the pane if successful. If the value is a plist, then it supplies details for the button, as described below, and can also contain the keywords 
:message
 to specify a message for the file prompter; 
:pathname
 to specify the default pathname of the file prompter (defaults to the text in the 
text-input-pane
) or any of the keywords 
:ok-check
, 
:filter
, 
:filters
, 
:if-exists
, 
:if-does-not-exist
, 
:operation
, 
:owner
, 
:pane-args
 or 
:popup-args
 which are passed directly to prompt-for-file.
A function that expects the pane as its single argument. The default is a function which sets text to the empty string.
Specifies a help button. The value must be a plist containing either keys 
:function
 and optionally 
:arguments
, or the keys 
:title
, 
:message 
and optionally 
:dialog-p
.
If function is supplied, when the user presses the help button it calls
(apply 
function
 
pane
 
arguments
)
where pane is the 
text-input-pane
. 
title
, 
message
 and 
dialog-p
 are ignored in this case.
Otherwise when the user presses the help button it opens a window with title 
title
 displaying the string 
message
 in a display-pane. The message can be long, and can include newlines. The window is owned by the pane, but is not modal, so the user can interact with the pane while the help window is displayed. If 
dialog-p
 is non-
nil
, the help window is raised as a dialog. The default value for 
dialog-p
 is 
nil
. 
function
 and 
arguments
 are ignored in this case.
The plist can contain other keys as described below.
The value is either 
:horizontal
 or 
:vertical
. 
orientation
 controls the orientation of the toolbar. This is useful for multi-line-text-input-pane. The default value is 
:horizontal
.
The value is 
:top
, 
:center
, 
:centre
 or 
:bottom
. 
adjust
 controls how the buttons are adjusted vertically relative to the text input pane. This is useful for multi-line-text-input-pane. The default value is 
:center
.
The value is 
:top
, 
:bottom
, 
:left
 or 
:right
. 
position
 determines whether the buttons appear above, below, left or right of the text input pane. If 
:position
 is not supplied, then the buttons appear to the right of the pane.
The value 
nil
 for 
buttons
 means there are no buttons - this is the default. When 
buttons
 is true the buttons appear or not according to their specified values or their default values.
All of the button plists (for 
:ok
, 
:cancel
, 
:help
 and so on) can contain the following keys and values in addition to those mentioned above:
A value that controls whether the button is enabled. (See the reader 
text-input-pane-buttons-enabled
).
The image to use for the button. This should be either a pathname or string naming an image file to load, a symbol giving the id of an image registered with register-image-translation, an image object as returned by load-image or an external-image. The default image is one of the symbols 
ok-button
, 
cancel-button
 or 
complete-button
, which are preregistered image identifers corresponding to each button.
The help-key used to find a tooltip for the button.
The 
text-input-pane-buttons-enabled
 reader returns a list containing keywords such as
:ok
, 
:cancel
 and 
:completion
, one for each corresponding button (as specified by 
buttons
) that is currently enabled.
The 
(setf text-input-pane-buttons-enabled)
 writer takes a list of keywords as described for the reader and sets the enabled state of the buttons, enabling each button if it appears in the list and disabling it otherwise. The value 
t
 can also be passed: this enables all the buttons.
For more than one line of input, use multi-line-text-input-pane.
The 
confirm-change-function
 was called 
before-change-callback
 in LispWorks 3.1. Both the old initarg 
before-change-callback and the old accessor text-input-pane-before-change-callback are still supported, but may not be in future releases.
(capi:contain (make-instance 'capi:text-input-pane
:text "Hello world"))
(setq tip (capi:contain
(make-instance
'capi:text-input-pane
:enabled nil)))
(capi:apply-in-pane-process
tip #'(setf capi:text-input-pane-enabled) t tip)
(capi:apply-in-pane-process
tip #'(setf capi:text-input-pane-enabled) nil tip)
(capi:apply-in-pane-process
tip #'(setf capi:text-input-pane-text) "New text" tip)
(capi:contain (make-instance
'capi:text-input-pane
:text "Hello world"
:callback #'(lambda (text interface)
(capi:display-message
"Interface ~S's text: ~S"
interface text))))
This example uses a plist value for the 
buttons
 key 
:cancel
 to specify that the Cancel button is initially disabled:
(capi:contain
(make-instance 'capi:text-input-pane
:buttons
'(:ok t :cancel (:enabled nil))))
This example shows how to specify a Help button which displays a help message:
(defvar *help-message* "A long help message.")
(capi:contain
(make-instance 'capi:text-input-pane
:buttons
`(:help
(:title "help window"
:message ,*help-message*))))
There is a further example in the file 
examples/capi/elements/text-input-pane.lisp
display-pane
editor-pane
multi-line-text-input-pane
text-input-choice
text-input-pane-complete-text
text-input-range
title-pane