Centre Generation Emploi <[EMAIL PROTECTED]> wrote:
> Is there any way to select individual lines within a scroll text field?

Bonjour Ann,

* You can use the hilite command to highlight one block of text
  at a time in a field member
* You can use the selection property to highlight one one block
  of text at at time in an _editable_ text member
* You need to use additional sprites to highlight separate blocks
  of text in either type of member, or to highlight a single block
  of text in an uneditable text member.

You can find an example of using two shape sprites to select a line in an
uneditable member at http://perso.planetb.fr/newton/hiliteText.dir

Below is a behavior that you uses Imaging Lingo to highlight any number of
individual paragraphs in a text member.  (Paragraphs end with a hard Return
character).  The behavior assumes that there is a bitmap sprite in the
channel above the text sprite that it is attached to.

Cheers,

James

--------------------------------------------------------------------------

property mySprite     -- sprite(me.spriteNum)
property myMember     -- Text member of mySprite
property myLineHeight -- Assumes fixed line height
--
property myBitmap     -- Bitmap member in sprite in following channel


on beginSprite(me)
  mySprite = sprite(me.spriteNum)
  myMember = mySprite.member
  
  -- Assume fixed line height in myMember
  myLineHeight = myMember.charPosToLoc(1).locV - 1

  tColor = rgb(0, 0, 255) -- HARDCODED blue hilite
  
  -- Prepare the bitmap member in the following sprite
  tSprite           = sprite(me.spriteNum + 1)
  tSprite.loc       = point(mySprite.left, mySprite.top)
  myBitmap          = tSprite.member
  tHilite           = image(mySprite.width, mySprite.height, 32)
  tHilite.fill(tHilite.rect, tColor)
  tHilite.setAlpha(0)
  tHilite.useAlpha  = TRUE
  myBitmap.image    = tHilite
  myBitmap.regPoint = point(0, 0)
end beginSprite 



on mouseUp(me) -- Permanently hilites the word under the mouse
  tLine  = mySprite.pointToLine(the mouseLoc)
  tChar2 = myMember.text.line[1..tLine].char.count
  if tLine = 1 then
    tChar1 = 0
  else
    tChar1 = tChar2 - myMember.text.line[tLine].char.count
  end if
  
  tLoc1  = myMember.charPosToLoc(tChar1 + 1) - [0, myLineHeight]
  tLoc2  = myMember.charPosToLoc(tChar2 + 1) + [0, 1]
  
  tRect  = rect(tLoc1, tLoc2)
  
  tHilite = myBitmap.image.extractAlpha()
  if tHilite.getPixel(tLoc1) = paletteIndex(0) then
    -- Hilite the word
    tColor = rgb(128, 128, 128) -- 50% transparency
  else
    -- A subsequent click removes the hilite
    tColor = rgb(255, 255, 255)
  end if
  
  tHilite.fill(tRect, tColor)
  myBitmap.image.setAlpha(tHilite)
end mouseUp

[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!]

Reply via email to