[futurebasic] Re: [FB] [FB3] Edit Fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2001 : Group Archive : Group : All Groups

From: "ronald b. kopelman" <rbkopelman@...>
Date: Wed, 25 Apr 2001 10:55:14 -0400
on 4/23/01 4:11 PM, Stuart Price wrote:

> Hi
> 
> This is probably an old question but here goes...
> 
> I am storing a log of data in a container and placing the entire contents of
> that container into an edit field replacing all of the previous text.  It
> works as I want it to except that the new text is selected, this causes a
> flickery effect as the new text repeatedly replaces the old text.  If I stare
> at this for a long time it causes me to type loose instead of lose ;-)
> 
> Does anybody know how to avoid this?
> 
> Stu
> 
> --
> 
> dim gDisplay as container
> 
> local fn ShowMessage(Msg as str255)
> gDisplay += Msg
> gDisplay += chr$(13)
> edit$(1) = #gDisplay
> setselect _maxInt,_maxInt
> end fn
> 
> window 1
> edit field -1,"",(10,10)-(400,200),_framed
> scroll button -1,,,,,(400,9)-(416,201)
> 
> dim i
> 
> for i = 1 to 100
> fn ShowMessage("Hello World" + STR$(i))
> next i
> 
> do
> handleevents
> until _false' Use CMD + '.' to exit

    I don't use containers much & it seems to me that if you are trying to
display their contents in an e-field you might be better off just using a
handle to avoid a potential text overflow. A few months ago in trying to
develop an Undo command I raised the same issue for text handles to no
avail. I tried to use GET FIELD ZTXThandle&, efID to save the contents of
the field & to restore it via EDIT$(efID) = &ZTXThandle& or EDIT FIELD efID,
&ZTXThandle&. The flicker drove me nuts. I even tried to restore the text &
the styles separately using Toolbox Calls to eliminate the flicker.

    I am not a professional programmer so I am sure that the following code
can be tweaked by the fb^3 gurus, but it did eliminate the flicker. The key
to it all is the activate/deactivate calls. Also, upon selecting the Undo
command, this routine also saves stuff so I can undo the Undo. The code may
be loose, but it lets me lose the flicker. Hope this helps. (Variables
starting with g are global.)

ronald b. kopelman
rbkopelman@...

_________________________________________________________

LOCAL FN preserveField(eFieldNum%)
dim err%, selectStart%, selectEnd%
dim textEditHandle as handle

SELECT eFieldNum%
CASE _inputEF'preserve input field
gUndoInputYear$=EDIT$(_inputEF)
CASE _outputEF'preserve output field
GET FIELD gUndoOutputHandle, _outputEF
textEditHandle = TEHANDLE(_outputEF)'preserve justification
gUndoJustification% = textEditHandle..teJust
END SELECT

END FN

_________________________________________________________

LOCAL FN undoField
dim err%, selectStart%, selectEnd%, tempJustification%
dim  5 tempYear$
DIM textEditHandle as handle
DIM tempOutputHandle as handle

SELECT WINDOW(_efNum)
CASE _inputEF
tempYear$ = gUndoInputYear$
FN preserveField(_inputEF)
EDIT FIELD _inputEF,tempYear$
CASE _outputEF
tempJustification% = gUndoJustification%
tempOutputHandle = gUndoOutputHandle
err% = FN HandToHand (tempOutputHandle)
LONG IF err% = _noerr
FN preserveField(_outputEF)
selectStart% = WINDOW(_selStart)
selectEnd% = WINDOW(_selEnd)
textEditHandle = TEHANDLE(_outputEF)
call TEDeactivate (textEditHandle)
call TESetJust(tempJustification%,textEditHandle)
EDIT$(_outputEF) = &tempOutputHandle
SETSELECT selectStart%,selectEnd%'must do before reactivation
call TEActivate (textEditHandle)
KILL FIELD tempOutputHandle
gDirtyFlag% = _true
END IF
if err% then beep
END SELECT

END FN