Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Tint bitmap behaviour
f3VideoCapture
Pretty Script
Tennis
Wait for a DirectMedia CuePoint(Name as Reference)
PopUp Menu
bkMixer
QuickTime Installer
ESCAPE Video Studio
Memory Info
 

 

 

Behavior PopUp Field

Added on 6/30/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC

This item has not yet been rated

Author: ChristofDaetwyler

Note that this is 3 parts. A movie script a frame script, and a behavior.

----------------------------------
--------- PART 1: THE MOVIE-SCRIPT
----------------------------------
on PopUpField SpriteNum,PopUpLineHandlers,PopUpLineShow
  ----- By Christof Daetwyler 1996
  ----- daetwyler@aum.unibe.ch
  ----- http://www.iawf.unibe.ch/Mitarbeiter/CDA/index.htm

  --  Parameters:
  --  SpriteNum: The SpriteNum of the field that we use as 'PopUp'
  --  PopUpLineShow: Text that has to be shown by the PopUp
  --  PopUpLineHandlers: Text where each line includes the handler
  --  according to the lines shown in the popUp

  global gLinks
  put PopUpLineHandlers into gLinks
  put 0 into gHilitePop

  -- Pop the menu up at the click location.
  put clickHV() into clickHV
  put value(item 1 of clickHV) into clickH
  put value(item 2 of clickHV) into clickV

  set the visible of sprite SpriteNum to false

  put PopLineShow into field (the name of member(the memberNum of sprite SpriteNum))

  PopUpMakeSmall SpriteNum, clickH, clickV

  updateStage
  set the visible of sprite SpriteNum to true
end

on PopUpMakeSmall SpriteNum,ClickH,ClickV
  ----- By Christof Daetwyler 1996
  ----- daetwyler@aum.unibe.ch
  ----- http://www.iawf.unibe.ch/Mitarbeiter/CDA/index.htm

  -- This script makes a text-Field as width as the longest line
  -- and sets it at the location specified with ClickH, ClickV
  -- The TextField MemberName should have a line and a shadow of 1 Pixel

  set the puppet of sprite SpriteNum to true
  put (the name of member(the memberNum of sprite SpriteNum)) into MemberName

  -- First, we have to find out, what line is the longest
  -- And how many characters are there until its end
  -- To use the Director 5 - lingo - Command
  put field memberName into inhalt
  put inhalt & return into inhaltX
  put 0 into X1
  put 0 into X2
  put 0 into X3
  repeat with t = 1 to the number of lines of inhalt
    put offset(numToChar(13),inhaltX) into X1
    delete char 1 to X1 of inhaltX
    put X1 + X2 into X2
    if X1 > X3 then
      put x1 into X3
      put X2 into CharNumLongestLine
      put X1 into CharCountLongestLine
    end if
  end repeat

  put inhalt into field MemberName

  put  ClickV into CV

  -- if the bottom of the PopUp-Field reaches the bottom of the stage, it has to be moved up
  -- probably you find a better solution - let me know
  put (the lineHeight of field MemberName) * (the number of lines of field MemberName) into HS
  set the height of sprite SpriteNum to HS
  if CV + HS > 480 then
    put 480 - HS into CV
  end if
  set the locV of sprite SpriteNum to CV
  set the locH of sprite SpriteNum to ClickH

  put the locH of sprite SpriteNum into x1

  -- first, the PopUp becomes as width as possible -> later we'll shrink it
  -- we use undocomented Lingo, because it's the only way to do it:
  set the rect of member memberName = rect(0,0,640,20)

  put string(charPosToLoc(member memberName,CharNumLongestLine)) into PointString
  put word 1 of PointString into PointString
  delete char 1 to 6 of PointString
  put Value(PointString) + x1 + 4 into x2
  put the locV of sprite SpriteNum - 2 into y1
  put the height of sprite SpriteNum + y1 + 6 into y2

  -- then, when we know how with the longest line is, we shrink to that rects:
  set the rect of member memberName = rect(x1,y1,x2,y2)

end

on PopUpLineHilite Nr, SpriteNum
  -- this script hilites line 'Nr' of Text-sprite SpriteNum
  put 0 into start
  put (the name of member(the memberNum of sprite SpriteNum)) into Name
  repeat with t = 1 to Nr - 1
    put length(line t of field Name) + start + 1 into start
  end repeat
  set Start to start + 1
  set End to start + (length(line (Nr) of field Name))
  hilite char Start to End of field Name
end

on PopUpsHide
  global gHilitePop
  put 0 into gHilitePop
  set the visible of sprite 47 to 0
end

on clickHV
  put string (the clickLoc) into clickHV
  delete char 1 to 6 of clickHV
  delete char (the number of chars of clickHV) of clickHV
  return clickHV
end

----------------------------------
--------- PART 2: THE FRAME-SCRIPT
----------------------------------

on exitFrame
  global gHilitePop
  -- In this case, the PopUp is Sprite Nr. 47

  if rollover(47) AND (the mouseDown = 1) then
    -- The mouse is over the PopUp Field
    -- Now the corresponding line has to be hilited

    put the mouseLine into mL
    put the mouseChar into mC
    if mL <> gHilitePop AND mL > 0 then
      PopUpLineHilite mL,47
      put mL into gHilitePop
      updateStage
    end if
  else
    if (the visible of sprite 47 = 1) then
      if (the mouseUp = 1) then
        -- The mouse was pressed over the PopUp-Field,
        -- but now it has been moved away from it and has been released
        PopUpsHide
      else
        set the hilite of field (the name of member(the memberNum of sprite 47)) to false
        put 0 into gHilitePop
      end if
    end if
  end if
  go to the frame
  updatestage
end

-------------------------------------------
--------- PART 3: THE POP-UP-FIELD - SCRIPT
-------------------------------------------

on mouseUp
  global gLinks
  PopUpLineHilite (the mouseLine),47
  do line (the mouseLine) of gLinks
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail