>> Hi,
>> 
>> this is my hilite code, but it have that problem i've mentioned. It not
>> selecte the entire line (the carriage return too).
>> 
>> on mouseDown
>> thisField = sprite(the clickOn).member
>> ML = the mouseLine
>> if ML <> -1 then
>> thisField.line[ML].hilite()
>> end if
>> end
>> 
>> If someone can point in how to make select all the line, i'll apreciate.
> ps:
>> it is a field cast member
>> 
>> Thank's in advance
>> 
>> Rodrigo Peres

When you say "select the line", what is your purpose? To actually set the
selection of the text so that it can be edited (in other words, a keystroke
will replace all of the selected text with the key), or just put emphasis on
a line by highlighting it?

If it's the second case, then perhaps you could set a higher sprite channel
to a rect shape, say with a 20% blend, and set the rect of that shape to the
line in question (this involves a bit more lingo, but gives you more control
- for instance, the color of the highlight is under your control, instead of
the user's system settings). All you need to do is get the on-stage locV of
the line - the other four points of the rect are determined by the field
itself.

Here's a rough behavior that does the above:

---------------
property pHiliteSprite

on beginSprite
  --Hardcoded for the purpose of example - change in "real life". Be sure to
put a holder in the channel that you set to pHiliteSprite.
  pHiliteSprite = 2
end

on mouseDown me
  baseLoc = sprite(me.spriteNum).Loc
  fieldTop = sprite(me.spriteNum).member.scrollTop
  myLineHeight = sprite(me.spriteNum).member.lineHeight
  clickedV = charPosToLoc(sprite(me.spriteNum).member, the mouseChar)
  
  baseV = (clickedV.locV - fieldTop) + baseLoc.locV
  
  hiliteTop = baseV - myLineHeight
  hiliteLeft = baseLoc.locH
  hiliteRight = baseLoc.locH + sprite(me.spriteNum).width
  
  sprite(pHiliteSprite).blend = 20
  sprite(pHiliteSprite).color = rgb(100,0,0)
  sprite(pHiliteSprite).ink = 0
  sprite(pHiliteSprite).rect= rect(hiliteLeft, hiliteTop, hiliteRight,
baseV)
  sprite(pHiliteSprite).member = member("basicRect")
end
---------------

This behavior is meant as an example - you'll need to do a little work on it
to make it fit with your code (and it's definitely not optimized, because
optimizing in this case might tend to obscure the steps that go into the
reasoning of the behavior) - it could be abstracted to a method call from a
behavior, which would be more flexible. But it should at least illustrate
the loc calculations you need to do to use a separate sprite to hilite text
lines.

Again, if you need to select text for editing, this is not the way to go (at
least not just this). But if you are simply emphasizing a line, then this
allows you to dictate the color, blend level, and/or ink of the hilite.

FWIW,
Kurt



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]

Reply via email to