At 00:11 -0800 02/12/2002, nitin sharma wrote:
>currently i m using ur script with moveablesprite
>true, but its not working, plz could u send me full
>script. in this script even i can't chage background
>color, for other chages i created other buttons by
>which user can make chages in text fields but they
>also not working on it.
Right, none of that stuff will work unless your program has a way to
gete a handle on the specific #text item that's meant to be changed.
See, by creating these things on the fly and putting them in the
score, you're actually kind of short-circuiting things a little and
making it tougher for you to make those kinds of changes.
That's why I suggested first attaching a behavior to a test #text
sprite that would let you make the changes you wanted without
creating it on the fly.
Unfortunately there is no easy way for me to send along a behavior
that does such a thing, because:
1. I don't know what properties you will wnat to change;
2. I don't know how you are intending to send the change commamnds; and
3. In producing something that worked well I'd basically be writing a
significant subset of code for you, and I actually can't do that
without charging you for it. :\
However what I can tell you is that you can put the whole thing into
a behavior and, when you create the #text sprite, instantiate and
attach the behavior.
The behavior itself should be able to "know" that it is attached to a
sprite which has been clicked for editing, and it should be able to
respond appropriately to orders to change contents (ideally sent via
sendAllSprites). Then it updates the #text member based on whatever
command you've sent from the color, font, etc. controls.
I'm not trying to be vague or abstruse here. What you're asking to do
is feasible but it's relatively complex and, because therea are so
many ways to actually write the text formatting behavior, there is
not a simple set of steps I can give you. The basic code would be
something like this:
PROPERTY pbSelected
on beginSprite me
me.setSelected( FALSE )
end
on setSelected me, bState
pbSelected = bState
sprite(me.spriteNum).member.editable = bState
the keyboardFocusSprite = me.spriteNum
end
on mouseUp me
sendAllSprites ( #setSelected, FALSE )
me.setSelected( TRUE )
end
on changeFace me, sNewStyle
-- this would be called from your bopld, italic, underline
-- buttons. If you called it from the "bold" button, that
-- button's script would be this:
-- sendAllSprites ( #changeFace, "bold" )
-- this is a very rough description only; you can have
-- multiple text styles (bold, italic) and of course you
-- want to be able to change colors and so on as well
-- but this is at least a place to get it started
if pbSelected then
sprite(me.spriteNum).member.textStyle = [ sNewStyle ]
end if
end
In order to get the final product working, set things up in a
separate movie which uses just one #text sprite, which has *not* been
created on the fly, and which is capable of receiving commands to
change its styling from your menu controls. Once you get that
self-contained behavior working, create a *second* #text sprite in
that movie and get things working so you can select one or the other
by clicking (the foregoing includes one method of doing so), and the
style changes you make only take effect in the selected item.
Once you've got that, you've got the behavior you need, and you can
go back and put it into your paint program, and attach it to your
#test sprites as you make them.
Assuming the behavior name is "textFormatCode", you would attach it like this:
on CreateTextSprite me, nOpenSprite
mNewText = new ( #text )
mNewText.editable = TRUE
puppetSprite nOpenSprite, TRUE
sprite(nOpenSprite).member = mNewText
sprite(nOpensprite).moveablesprite=true
sprite(nOpenSprite).ink = 36
oScript = new ( script "textFormatCode" )
sprite(nOpenSprite).scriptList = [ oScript ]
END CreateTextSprite
I know this is a thorny issue, especially if you're still getting the
hang of Lingo, but the above might be enough to get you started at
least.
--
Warren Ockrassa | http://www.nightwares.com/
Director help | Free files | Sample chapters | Freelance | Consulting
Author | Director 8.5 Shockwave Studio: A Beginner's Guide
Published by Osborne/McGraw-Hill
http://www.osborne.com/indexes/beginners_guides.shtml
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]