[futurebasic] Re: [FB] Field class again

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Sat, 28 Aug 1999 20:26:24 -0500

Stewart wrote:

> Another Class question
> I am trying To get the class of an edit fiele by using TEHANDLE  per
> Ref.book Page3.5. I want it to determine the class of a field a user is
> entering Data in.
>  efJust% = TEHANDLE&..teJust%
> But on close examination, it turns out that as far as the ToolBox is
> concerned, teJustRight = -1 and teLeftJust = 0. (teCenterJust turns out
> to be 1).
> But it doesnt make any difference what multiple of 4 is added to the
> just parameter in ther window definition, the Toolbox ignores it.
> So how can I get the class of an edit field?

As you've discovered, TEHANDLE returns a handle to the field's "TextEdit
Record."  The TextEdit Record is something that's maintained by the MacOS (is
not a uniquely-FB thing).  On the other hand, the edit field's "class" _is_
something that's unique to FB, and FB stores it in a private data structure.

The simplest way to get the class of an edit field is to use the
WINDOW(_efClass) function.  There are two things you should note about

* It only returns information about the currently-active edit field in the
current output window.  The "currently-active" field is essentially the one
that's currently receiving keypresses.  If none of the fields in the current
output window is currently active, then the value returned by WINDOW(_efClass)
is undefined.

* The number that it returns is actually the same number that you assigned as
"justify + class" in the EDIT FIELD statement.  This is somewhat confusing in
the manual.  You have to "tease out" the class number from the value returned
by WINDOW(_efClass).

For example, if you create the edit field like this:

EDIT FIELD #5, "Hello", (10,50)-(100,66), _framedNoCR, _leftJust + myClass*4

Then the number you will get back from WINDOW(_efClass) is this:

_leftJust + myClass*4

To get back the original value of "myClass", use this:

WINDOW(_efClass) / 4

If you need to get the class number of a field which is not the currently
active field in the current output window, you can use the WNDBLK function to
help you do it.  This is a little more complicated, but if you have a
requirement to do it, let us know and we'll show you how.

- Rick