FutureBasic Logo

<<    Index    >> FutureBasic 5

edit field   statement

edit field [#]idExpr [,[text][,[rect][,[type],¬ [efClass],[keyFilterProc]]]]
edit field -idExpr
edit field 0

Use this statement to perform any of the following actions in the current output window:
In the new Appearance Manager runtime, edit fields are actually buttons. FutureBasic creates special controls called user panes that allow styled text to be present. It is important to note that items created with the edit field statement are different from those created with the appearance button statement. Text items made with appearance button do not accommodate multiple runs of styled text, proper scrolling, and other necessary items. Text items created with the edit field statement have most of the features found in Standard BASIC edit fields with the added advantages of Appearance Manager compliance.
To disable an Appearance Manager field, use edit field with a negative value. To gray out field #22, you would use the statement edit field -22.
In FutureBasic, an edit field can be either static or non-static. A static edit field contains text that is used for display purposes only; the user cannot edit the contents of such a field. A non-static field is editable; the user can use mouse and keyboard commands to edit the field's contents. It is possible for the program to change a field's type from static to non-static (or vice-versa); this is sometimes useful when you want to temporarily inhibit the user from editing some text. The Appearance Manager adds the ability to create "copy only" fields in which text may be selected and copied to the desk scrap but may not be edited.

Key Filter Procs
It is possible to filter key presses directed at fields in the Appearance Manager. The Appearance Manager has the ability to direct every keypress destined for a target field to a special procedure which you establish in your program and point to at the time the field is created. The following fully functional example creates a simple numeric filter that limits field entry to the digits zero through nine.
local fn numeralFilter
  dim k as Str15
k = tekey$
long if k >= "0" and k <= "9"
    tekey$ = k
select asc( k )
     case < 32 : rem allow for control keys
      tekey$ = k
case else
    end select
  end if
end fn

dim @ filter as pointer
dim r as Rect

window 1
SetRect( r, 10, 10, 450, 60 )
filterFN = @fn numeralFilter
edit field 1, "Numbers Only", @r,,, filterFN

do HandleEvents until 0
A non-static (editable) field can be either active or inactive. In the frontmost window, an active field contains the blinking insertion point or a highlighted selection; it is the field whose contents the user is currently editing. At most one field in the window can be active at any given time; whenever a field becomes active, all other editable fields in the window become inactive. It is also possible to inactivate all of the editable fields in a window.
If your window contains an active edit field, then your program should call HandleEvents periodically (it's a good idea for your program to do this in any case). This will allow the user's keypresses and mouse events to be transmitted to the active field as appropriate, and will cause the field's contents to be updated correspondingly. Your program can use the edit$ function or the get field statement to check the contents of a field at any time.
FutureBasic automatically refreshes (redraws) both static and non-static edit fields as necessary, unless the window's _noAutoClip feature is set.
To create a new edit field: Specify a positive or negative number in idExpr, such that abs(idExpr) is different from the ID numbers of all other existing edit fields or picture fields in the current window. The rect parameter is required in this case. If idExpr is positive, then a "non-styled" edit field is created, and is assigned an ID number equal to idExpr. If idExpr is negative, then a "multistyled" edit field is created, and is assigned an ID number equal to abs(idExpr). A "non-styled" edit field adopts the text characteristics (font family, size, style and color) that were in effect for the window at the time the field was created, and all the text in that field has those characteristics. A "multistyled" edit field can contain different pieces of text which each have different text characteristics. NOTE: When you create a new non-static edit field, the new field becomes the active field in that window.
When you create a new edit field, any parameters that you omit have these default values:
To activate an existing non-static edit field: Specify the ID number of the existing field in idExpr. You don't need to specify any other parameters, unless you also wish to alter some of the field's characteristics.
To modify the characteristics of an existing edit field: Specify the ID number of the existing field in idExpr, and specify one or more of the other parameters. Any parameter that you omit won't have its characteristic changed. Note that if the field is editable (non-static), this command will also make it the active field.
If the only thing you want to change about the field is its contents, then you can alternatively use the edit$ statement. The edit$ statement will not make the field active.
To inactivate all edit fields in the window: Use the edit field 0 syntax.
To make a static field editable: You can Specify any of the editable types in the type parameter.
Note: Changing a static field to an editable field also makes the field active.
To make an editable field static: First, deactivate the field (either by executing edit field 0 or by activating a different field), and then specify any of the static types in the type parameter.

The following sections explain the use of the various parameters.

This parameter can be specified in any of the following forms:
The field's contents are completely replaced by the specified text. The various forms of this parameter are interpreted the same way as in the edit$ statement; see the edit$statement for more information.

This parameter specifies the "view rectangle" for the field. No text will be drawn outside of this rectangle. This parameter can be specified in either of the following forms:
This is an integer which specifies several characteristics about the field.
Please note that not all of the old FBII style field types are available for the Appearance Manager Runtime. The following list shows all of the types that are not available for Appearance projects:
_statFramedInvert + _hilite
_statNoFramedInvert + _hilite

The following 24 types only are supported, (each in two forms, with and without _usePlainFrame, making 48 altogether):
_copyOnlyNoFramed _copyOnlyNoFramed_autoGray
_framedNoCR _framedNoCR_autoGray
_framed _framed_autoGray
_noFramedNoCR _noFramedNoCR_autoGray
_noFramed _noFramed_autoGray
_framedNoCR_noDrawFocus _framedNoCR_autoGray_noDrawFocus
_framed_noDrawFocus _framed_autoGray_noDrawFocus
_noFramedNoCR_noDrawFocus _noFramedNoCR_autoGray_noDrawFocus
_noFramed_noDrawFocus _noFramed_autoGray_noDrawFocus
_statFramed _statFramed_noAutoGray
_statNoFramed _statNoFramed_noAutoGray
Editable (non-static) types:

_framedNoCR (1)
Frame is drawn. "Return" key does not advance line, but generates an _efReturn event. This is the default type.
_framed (2)
Frame is drawn. "Return" key advances insertion point to next line, does not generate an _efReturn event.
_noFramedNoCR (3)
Like _framedNoCR, but no frame is drawn.
_noFramed (4)
Like _framed, but no frame is drawn.
_statFramed (5)
Frame is drawn.
_statNoFramed (7)
No frame is drawn.
_statFramedGray (9)
Frame is drawn; frame and text are dimmed.
_statNoFramedGray (11)
No frame is drawn; text is dimmed.
_statFramedInvert (13)
Frame is drawn; text and background colors are inverted.
_statNoFramedInvert (15)
No frame is drawn; text and background colors are inverted.
_statFramedInvert+hilite (29)
Frame is drawn; text and background are highlighted using system highlight colors.
_statNoFramedInvert+hilite (31)
No frame is drawn; text and background are highlighted using system highlight colors.
_noDrawFocus (256)
Use this option if you don't want the focus rectangle outlining the active field.
_noAutoGray (512)
When the window goes to the background, text in this field will not be grayed.
_autoGray (1024)
Text is automatically grayed when the window goes to the background.
_copyOnlyFramed (2048) The user may selct and copy text from this field but may not edit the text.
_copyOnlyNoFramed (2051) This is the same as _copyOnlyFramed without the frame.
_usePlainFrame (4096) When added to a _framed or _framedNoCR type, gives an old-fashioned but crisp rectangular frame instead of the trendy fuzz obtained with DrawThemeEditTextFrame. The runtime currently requires a frame/CR constant to be supplied as well as the special _usePlainFrame. Thus you will have to specify: _framedNoCR_usePlainFrame
This parameter must be within the range 0 through 255 (0 through 536,870,912 in the Appearance Manager). It serves two purposes:
If efClass is zero, then the text will be left-justified. Otherwise, text justification is determined by the low-order two bits in efClass (given by efClass mod 4), as follows:
If efClass mod 4 is:
Then the text is:
Right justified.
_leftJust (1)
Left justified.
_centerJust (2)
_rightJust (3)
Right justified.
If you just want to set the field's text justification, and you don't care about its "class," then the easiest thing to do is just to set efClass to one of the constants _leftJust, _centerJust or _rightJust.

An edit field cannot contain more than 32,767 characters of text.
The edit field statement is not the only means by which an inactive field can become active. If the user clicks on an inactive editable field, FutureBasic automatically activates the field the next time your program executes the HandleEvents statement.

See Also:
HandleEvents; edit text; edit$ statement; edit$ function; read field