If the pattern and template do not provide enough valida tion, or if there is no template, there is also the possi bility of using a callback after each character is entered. The callback can accept or reject the new text.
The rvStart resource is used as cursor position.
Public variables
______________________________________________________
XtNtemplate
The template consists of text with at least one `_'
(or, to be precise, the value of placeholder). If there
is no template, input of any length is accepted (but
see the validate callback below).
Note that the label resource that is inherited from XfwfLabel is used to hold the combination of template and text. Setting label has no effect, and, indeed, will cause a warning message to be printed.
XtNpattern
The pattern is only used if there is a template. The
length of the pattern must be the length from the first
`_' in template to the last. Where the template has a
`_', the pattern must have one of:
* `9' only digits are allowed.
* `a' digits, upper- and lowercase letters and spaces.
* `A' digits, uppercase letters and spaces.
* `F' only `safe' file name characters.
* `f' file name character plus `*' `[', `]' and `?'
* `X' any character.
* `z' digits, upper- and lowercase letters (no spaces)
* `Z' digits, uppercase letters (no spaces).
If the pattern is empty or too short, it will be extended with X's.
XtNvalidate
The validate callbacks are called when the text
changes, because a letter is added or removed. The
callback get a pointer to an XfwfPromptInfo structure
as call_data. The structure includes a field reply,
which should be set to XfwfReject, XfwfAccept or Xfwf
Complete. The first causes the new text to be rejected
with a `beep'; the second sets the complete resource to
False, to indicate that the text is valid, but not yet
complete; the third sets the complete resource to True.
XtNleave
The leave callback is called when the focus leaves the
prompt widget. This is usually a sign that the user is
ready entering the text. The final text is passed in
the call_data argument.
XtNactivate
The activate callback is invoked from the activate
action, which is normally bound to the Return key. The
call_data argument of the callbacks routines is filled
with a pointer to the event that triggered the action.
This callback can be used in a dialog box, for example,
to activate the default button.
XtNcomplete
The resource complete is always True, unless the most
recent call to the validate callback returned XfwfAc
cept.
XtNplaceholder
The character thatis used as the placeholder can be
changed from the default `_' by setting the placeholder
resource. Note that this character will also be used in
the text string to indicate open places.
XtNcursor
The cursor is by default a vertical bar, called the
`xterm' cursor.
XtNtraversalOn
Since prompts, in contrast to labels, should receive
keyboard events, the traversalOn resource is by default
True.
XtNframeWidth
The default frame width is also given a different
value.
XtNframeType
As is the frame type
XtNalignment
The default alignment of text is changed to centerleft.
_______________________________________________________________________ | XfwfLabel | Name | Class | Type | Default | XtNlabel | XtCLabel | String | NULL | XtNtablist | XtCTablist | String | NULL | XtNfont | XtCFont | FontStruct| XtDefaultFont | XtNforeground | XtCForeground | Pixel | XtDefaultForeground | XtNhlForeground| XtCHlForeground| Pixel | XtDefaultForeground | XtNalignment | XtCAlignment | Alignment | 0 | XtNtopMargin | XtCTopMargin | Dimension | 2 | XtNbottomMargin| XtCBottomMargin| Dimension | 2 | XtNleftMargin | XtCLeftMargin | Dimension | 2 | XtNrightMargin | XtCRightMargin | Dimension | 2 | XtNshrinkToFit | XtCShrinkToFit | Boolean | False | XtNrvStart | XtCRvStart | Int | 0 | XtNrvLength | XtCRvLength | Int | 0 | XtNhlStart | XtCHlStart | Int | 0 | XtNhlLength | XtCHlLength | Int | 0 | | | | |________________|_________________|____________|______________________
<FocusIn>: focusIn()
<FocusOut>: leave() focusOut()
removed:
trans <Visible>: visibil
ity()
removed:
trans <Unmap>: unmap()
<Key>Up: traverseUp()
<Key>Down: traverseDown()
<Key>Next: traverseNext()
~Shift<Key>Tab: traverseNext()
<Key>Prior: traversePrev()
Shift<Key>Tab: traversePrev()
<Key>KP_Enter: traverseNextTop()
<Key>Home: traverseHome()
Shift<Btn1Down>: extend_select()
<Btn1Down>: traverseCurrent() start_select()
<Btn1Motion>: extend_select()
<Btn1Up>: end_select()
<Btn2Down>,<Btn2Up>: paste()
<Key>BackSpace: cut() backspace()
Ctrl<Key>d: cut() delete()
<Key>Right: unselect() right()
<Key>Left: unselect() left()
Ctrl<Key>a: unselect() bol()
Ctrl<Key>e: unselect() eol()
<Key>Return: activate()
<Key>: cut() self_insert()
leave
The leave action calls the leave callbacks with the current text as call_data.
start_select
The start_select action sets the cursor position as close as possible to the mouse position, but only if the mouse actually points at some text. It also removes any previous selection, preparing for a new one.
extend_select
The extend_select action extends the selection to the current cursor position.
end_select
The end_select action copies the selected text to the clipboard.
paste
The paste action requests the contents of the clipboard in string-format and tries to insert it into the text.
unselect
The unselect action restores the text that was shown in reverse to normal.
cut The cut action deletes the highlighted portion from the text.
self_insert
The self_insert function inserts the key that was pressed into the text. If the key is not a printable key, it does nothing. If the key doesn't match the pat tern, it does nothing. If the callback validate returns XfwfReject, it does nothing.
left The left action moves the cursor one position to the left, unless there are no more placeholders in that direction.
right
The right action moves the cursor one position to the right, unless it is already at the end of the template.
delete
The delete action removes the character to the right of the cursor, if there is any. The rest of the characters in the same run will shift to the left.
backspace
The backspace action removes the character to the left of the cursor, if there is any. The cursor moves left and all characters in the same run move left.