REBOL

FIELD - Improved VID Field

Quick Manual

FIELD is a superset of the ordinary VID field with an extra set of useful functions for evaluating the contents and provides more control over key presses. This way, you don't have to mess around with the FEEL object as much, and you can write much less code. It has the same name as the current FIELD, so you can drop it into your existing code.

Right now, the new FIELD only does a limited set of things, but hopefully it will grow and eventually, it's hoped that the features will eventually creep into the official VID.

The new FIELD is currently in version 0.0.2.

Installation

You can get it from here.

Or you can do this:

do http://www.hmkdesign.dk/rebol/vid/src/vid-field.r

And you're ready to go!

Examples

view layout [
  field
]

This provides a FIELD that looks and behaves like a regular FIELD.

view layout [
  field numeric
]

This provides a FIELD that only accepts numeric keypresses, like 0-9, comma (,), punctuation (.) and + and -. Both positive, negative, integers and decimals are supported.

view layout [
  field key-action [print get-face face]
]

This provides a FIELD that will perform the action given in the block on every single key press. You have access to the same parts of the face as through any normal action.

view layout [
  field key-action [probe event/key]
]

Above, as you can see, you also have access to the event port.

view layout [
  field key-action [probe event/key] [print "Leaving field!"]
]

Of course like the regular field, you have access to the normal action as well. The normal action is performed before key-action.

view layout [
  field key-range [#"a" - #"f" #"A" - #"F" #"0" - #"9"]
]

This defines a limited key range for the field, so it only accepts hexadecimal input. The syntax for the block is the same as for creating bitsets.

view layout [
  field numeric range [0 15]
]

This defines the range of numbers allowed to be used in the field. If any other number is entered, the number will be confined to the range, when you leave the field.

view layout [
  field numeric numeric-keys range [0 15]
]

Same as before, except + and - keys are now usable to adjust the number. numeric-keys only works together with numeric.

view layout [
  field max-length 5
]

This will restrict the length of the input in the field to 5 chars.

view layout [
  a: field next-face 'c
  b: field next-face 'a
  c: field next-face 'b
]

This will allow you to tab to a specific field or any other face, as long as it's provided as a lit-word!.

view layout [
  a: field back-face 'c
  b: field back-face 'a
  c: field back-face 'b
]

Same as the above, except back-face works on shift+Tab.

NAME-FIELD

name-field is a field with a specific KEY-ACTION suitable for entering names. On each keypress it converts each letter at the start of the text and after each space to uppercase, removes double spaces and trims the head of the text.

When tabbing out, the text is trimmed at the tail as well.

Usage:

view layout [name-field]

If you want to extend the key-action for name-field, you can append more code to the key-action block:

view layout [name-field with [append key-action [probe event/key]]]

User Interaction

Numeric fields can be altered using the + and - keys, when numeric-keys is enabled. You can always alter the number, using the scroll-wheel. When holding ctrl while using the scroll-wheel or the +/- keys, it will increment/decrement in steps of 10 instead of 1.

MakeDoc2 by REBOL - 3-Sep-2007