Highlighting text in uneditable Text members is not
a simple matter. You can highlight text in an editable text member
by setting the keyboardFocusSprite to the appropriate sprite, then setting
the .selection property of the Text member. With uneditable
Text members, this has no effect.
Because of this shortcoming, highlighting a selection of
uneditable text requires a separate sprite. So why not exploit this fact
to create a multiple selection highlight?
The movie above demonstrates a Multiple Selection behavior
that you can attach to any Text sprite. You need to provide a Bitmap sprite
in the next channel. The behavior sets the colour of the Bitmap member,
then modifies the alpha channel to make areas of the Bitmap sprite visible.
Hold the Shift Key down as you click and drag to make a continuous selection;
hold the Control Key (Windows) or the Command Key (Macintosh) down as
you click to select or deselect discontiguous lines.
The behavior includes GetSelection() and SetSelection()
methods, so you can modify the selections from other scripts and perform
actions in other scripts based on the current selections. In the movie
above, these handlers are used to update the display of selected lines,
and to allow you to change the selection by choosing from a set of checkboxes.
The highlit areas update automatically as the user scrolls
the text. There may be a slight lag, especially when the user presses
the scroll arrows, as the System deals with the text scrolling, and only
hands control back to Director when the scrolling is done.
If you click on the Text member then drag beyond the top
of the sprite or below the bottom of the sprite, the Text member will
scroll automatically. If you hold the Shift Key down while you do this,
the selection will extend to the area of the sprite that scrolls into
view.
James Newton started working with Director 5 in 1997. He wrote many of the
behaviors that ship with Director since version 7. James lives in Dunoon,
near Glasgow, Scotland. His company, OpenSpark Interactive, is responsible
for marketing PimZ OSControl Xtra. When not coding he can be found racing
his classic Flying Fifteen around the Holy Loch, making things with his four
children, or catching escaped hamsters.