>Has anyone accomplished an input field that scrolls as the user types?
>AND when the user highlights with the mouse?
Hi Arlen,
The easiest method would be to use a scrolling field...
Menu: Modify > Cast Member > Properties...
then select "Scrolling" in the "Framing" pop-up menu.
You may have a good reason using a field with #fixed boxType instead (if
you want to use a custom scrollbar for instance).
You can quite easily make the field scroll as the user types. Here's a
behavior that does this:
property thisSprite
property mySpriteHeight
property myFieldMember
property myScroll
on beginsprite me
set thisSprite to the spriteNum of me
set mySpriteHeight to the height of sprite thisSprite
set myFieldMember to the member of sprite thisSprite
end
on prepareFrame me
if the selStart = the selEnd and the selEnd then
set startV to the locV of charPosToLoc (myFieldMember, the selStart + 1)
if (startV > mySpriteHeight + myScroll) or (startV < myScroll + 1) then
set myScroll to min (the height of myFieldMember - mySpriteHeight, ¬
max (0, startV - mySpriteHeight))
set the scrolltop of myFieldMember to myScroll
end if
end if
end
Scrolling-as-the-user drags is possible but it is not a trivial exercise.
You must take full control of the way the text is hilited.
Lingo handles hilites in an "idiosyncratic" manner. Here are some of
the problems that you will face:
* The field's sprite span has to be one fifth as long again as the loop
between the marker and the "go loop" frameScript (Don't ask me why).
(There is no problem if you use "go the frame").
* You must set the editable of the field to FALSE as you drag. When you
mouseDown on an editable field the playBack head stops until you
release the mouse again.
* This means you must set the editable of the field back to TRUE when you
release the mouse. Lingo hilites don't "stick" easily to an editable
field (except from the Message Window). You have to wait until the
playback head has reached the next frame after you release the mouse
at the end of the drag... and then hilite the selection again.
* Director muddles its hilites. It is quite happy to create a new hilite
without clearing the previous one. This can lead to a strange situation
where the selection is normal, and all the text around is hilit.
* And so on...
If I remember right, I spent something like eight hours wrestling with
all this. As a result, I have a behavior which is "cleaner" (but
slower) than the built-in scrolling fields. The code is too long to post
on Direct-L. Mail me direct for more information.
James Newton
D. Plänitz