|
|
Limited Text Behavior
Added on 9/8/2000
|
Drop this behavior on a field to make it editable.
This behavior counts the number of words, entered in the editable field, and displays an alertmessage if the number of words, specified by the author is exeeded. enter the number of allowed words and your custom alertmessage in the parameterdialogbox, in it, you can also change some fontproperties .
Download PC Source Download Mac Source
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--
-- Drop this behavior on a field to make it editable.
-- This behavior counts the number of words, entered in the editable field,
-- and displays an alertmessage if the number of words, specified by the
-- author is exeeded. enter the number of allowed words and your custom
-- alertmessage in the parameterdialogbox, in it, you can also change some
-- fontproperties .
--
-- Kurt Koenig * Belgium. -- Director 7 --
-- -- Director 8 --
--
--
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
property pLimitedField, pTSMember, pWordCount,¬
pAlert, pTheFontSize, pTheFontStyle
on getPropertyDescriptionList me
desclist = [:]
addprop desclist, #pWordCount,[#comment: "How many words¬
are allowed in this field ?",#format: #integer, #default:"10"]
addprop desclist, #pAlert,[#comment: "Enter an alertmessage¬
to display if exeeded ",#format: #string, #default:"Explain¬
it in 10 words or less please !"]
addprop desclist, #pTheFontSize,[#comment: "Fontsize to use :",¬
#default:12,#format:#integer,#range:[#min:9,#max:96]]
addprop desclist, #pTheFontStyle,[#comment: "Fontstyle to use :",¬
#format: #symbol, #range : [ #plain, #bold, #italic], #default: #plain ]
return desclist
end getPropertyDescriptionList
on getbehaviordescription
return¬
"This behavior determines how many words"&return&"¬
an editable field allows, and displays an"&return&"¬
alert if the number of words, specified"&return&"¬
by the author is exeeded..."&return&return&"¬
Kurt * Belgium"
end getbehaviordescription
on getBehaviorTooltip me
return "¬
"This behavior determines how many words"&return&"¬
an editable field allows, and displays an"&return&"¬
alert if the number of words, specified"&return&"¬
by the author is exeeded..."
end getBehaviorTooltip
on beginsprite me
pLimitedField = sprite (me.spritenum)
pTSMember = pLimitedField.member
pTSMember . editable = true
pTSMember . autoTab = TRUE
pTSMember. fontsize = pTheFontSize
pTSMember . fontstyle = pTheFontStyle.string
end beginsprite
on exitframe me
if pTSMember. words . count <= pWordCount then
nothing
else
if pTSMember. words . count > pWordCount then
delete pTSMember. word[(pwordcount + 1)]
Alert pAlert
end if
end if
end exitframe
|
|