Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Sprite Group Movement behavior
Read a File
Font Pages
Useful list functions
Dervich Pivot Xtra
DirectOS Xtra
SkyDir
myScreen
Flash Paper in Director Article
Director Web
MediaMacros Xtras Mall
 

 

 

Behavior Hilite Lines - Text and Field

Added on 5/9/2001

 

Compatibilities:
behavior D7 D8 D8_5 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

This fakes a line hilite (of the entire line) for a text and field member.

Download PC Source    Download Mac Source
property spriteNum
property pHiliteSprite
property pCurrentLine
property pLastScrollTop
property pWhatAction

on beginSprite me
  --set the current scrolltop
  pLastScrollTop = sprite(spriteNum).member.scrolltop
  --nothing currently selected
  pCurrentLine = 0
  --build tracklist
  me.makeRectAround()
end

on getPropertyDescriptionList me
  p = [:]
  p.addProp(#pHiliteSprite, [#format : #integer, #comment : "What sprite is the hilite shape in?", #default : the currentSpriteNum + 1])
  p.addProp(#pWhatAction, [#format : #symbol, #comment : "What action to trigger the rollover?", #default : #rollover, #range : [#rollover, #click]])
  return p
end

on mouseUp me
  if pWhatAction = #click then
    --get the line
    selectedLine = me.getLine()
    if selectedLine = pCurrentLine then
      --deselect
      pCurrentLine = 0
    else
      pCurrentLine = selectedLine
    end if
    me.makeRectAround()  
  end if
end

on getLine me
  if sprite(spriteNum).member.type = #text then
    return pointToLine(sprite spriteNum, the mouseLoc)
  else if sprite(spriteNum).member.type = #field then
      return locVToLinePos(sprite(spriteNum).member, the mouseV - sprite(spriteNum).member.scrolltop - sprite(spriteNum).top)
      end if
end

on getLineHeight me
  if sprite(spriteNum).member.type = #text then
    a1 = 0
    if pCurrentLine > 1 then
      a1 = linePosToLocV(sprite(spriteNum).member, pCurrentLine - 1)
    end if
    a2 = linePosToLocV(sprite(spriteNum).member, pCurrentLine)
    return (a2 - a1)
  else if sprite(spriteNum).member.type = #field then
    return sprite(spriteNum).member.lineheight    
  end if
end

on exitFrame me
  if pWhatAction = #click then
    --check to see if we have scrolled
    if pLastScrollTop <> sprite(spriteNum).member.scrolltop then
      pLastScrollTop = sprite(spriteNum).member.scrolltop
      me.makeRectAround()
    end if
  end if
end

on mouseEnter me
  if pWhatAction = #rollover then
    selectedLine = me.getLine()
    pCurrentLine = selectedLine
    me.makeRectAround()  
  end if
end

on mouseLeave me
  if pWhatAction = #rollover then
    pCurrentLine = 0
    me.makeRectAround()  
  end if
end

on mouseWithin me
  if pWhatAction = #rollover then
    selectedLine = me.getLine()
    if selectedLine <> pCurrentLine then
      pCurrentLine = selectedLine
      me.makeRectAround()
    end if
  end if
end

on makeRectAround me
  if pCurrentLine > 0 and pCurrentLine <= sprite(spriteNum).member.line.count then
    --get the height of the line
    lHeight = me.getLineHeight()
    --get the scrolltop
    myScrollTop = sprite(spriteNum).member.scrollTop
    myRectTop = sprite(spriteNum).top + (lHeight * (pCurrentLine - 1)) - myScrollTop
    myRectBottom = myRectTop + lHeight
    if myRectBottom >= sprite(spriteNum).bottom and myRectTop <= sprite(spriteNum).bottom then
      --cut short below
      myRectBottom = sprite(spriteNum).bottom
    else if myRectTop >= sprite(spriteNum).bottom then      
      --below the line      
      myRectTop = -1000
      myRectBottom = -1000
    else if myRectBottom <= sprite(spriteNum).top then
      --above the line
      myRectTop = -1000
      myRectBottom = -1000
    else if myRectTop <= sprite(spriteNum).top and myRectBottom >= sprite(spriteNum).top then
      --cut short
      myRectTop = sprite(spriteNum).top
    end if
    --set the rects
    myWidth = sprite(spriteNum).width
    sprite(pHiliteSprite).rect = rect( sprite(spriteNum).left, myRectTop, sprite(spriteNum).left + myWidth, myRectBottom)
    sprite(pHiliteSprite).rect = rect( sprite(spriteNum).left, myRectTop, sprite(spriteNum).right, myRectBottom)
  else
    sprite(pHiliteSprite).loc = point(-1000,-1000)
  end if
end

on getBehaviorDescription me
  return "Drop this on a text member and give it the number of a sprite with a QuickDraw member set to reverse ink. (In a higher channel than the text sprite)"
end

on getBehaviorTooltip me
  return "Drop this on a text member and give it the number of a sprite with a QuickDraw member set to reverse ink. (In a higher channel than the text sprite)"
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail