-- These routines are a portion of Kurt Cagle's -- Lingo Database code, and are copyright 1995. -- For more information on their use, or just -- to BS with him about matters Lingo, please -- e-mail him at CagleK@aol.comOkay, a quicky. The following two routines are used to do a quick single or multiline selection of lines in a text field, using the text attributes of the words in place. Explanations follow the routines:
on markline attribute,multilineFlag
set curline=the mouseline
if curline<1 then return 0
set fieldname=the name of cast (the castnum of sprite (the clickon))
put the textstyle of line curline of field fieldname into curstyle
if not(multilineFlag) then
set the textstyle of field fieldname to "plain"
end if
if voidP(attribute) then set attribute="bold"
if curstyle=attribute then
set the textstyle of line curline of field fieldname to "plain"
return "plain"
else
set the textstyle of line curline of field fieldname to attribute
return attribute
end if
end markline
on getMarkedLineList fieldname,attribute
if voidP(attribute) then set attribute="bold"
set entrylist=[]
repeat with i=1 to the number of lines of field fieldname
if the textstyle of line i of field fieldname=attribute then
add entrylist,line i of field fieldname
end if
end repeat
return entrylist
end getMarkedLineList
on setfield fieldname,attribute
if voidP(attribute) then
set attribute="plain"
end if
set the textstyle of field fieldname to attribute
return attribute
end setfield
A bit of explanation...
Setfield will set the text style of
a given field to the attribute listed, i.e.
"plain","bold","italics"
the default (when no attribute is given)
is "plain"
Markline is placed in a field's cast or score script. The first parameter, attribute,is the standard text styles (as noted above, with the default being "bold". When someone clicks on the field, the routine turns the element clicked on to the attribute in question if the element had not previously been selected, or turns it to plain if it had. The second parameter, is a flag. If it is set to TRUE or #multiline, then multiple lines can be selected. Otherwise, only one line will be selected at any given time.
GetMarkedLineList is a handler that will return a list of all lines that are set to the given attribute. The assumption with this handler is that the selected items are marked by the "bold" attribute, while unmarked items are marked by "plain", but a different attribute can be tested for by explicitly stating it as a parameter. The advantage to that is that there is more than one way to select an object, and each attribute type could have a distinct meaning. This handler can be called from a movie script, and returns a linear list of each of the lines.
-- These routines are a portion of Kurt Cagle's -- Lingo Database code, and are copyright 1995. -- For more information on their use, or just -- to BS with him about matters Lingo, please -- e-mail him at CagleK@aol.com