Well, its just as well you didnt see it. I made a mistake while pasting the
behavior. See it as a .dcr at www.geocities.com/pranav_negandhi/menus.htm
Sorry for the goof up guys...   :-]

Meanwhile, here's the text of the behavior.

-- Use to build a series of hierachical menus
-- Created by Pranav Negandhi
-- Date 5/2/2001

-- 6/2/2001 Pranav Negandhi
-- Bug Menus of different pMenu remained open simutaneously.
-- Cause Since the menu id was different, 2 separate menus
-- hierarchies did not register with each other as relatives.
-- Solution Removed the pMenu property

-- 7/2/2001 Pranav Negandhi
-- Feature Integrated the perform action behavior with existing code
-- Now, developers can define the action to perform within this
-- behavior itself, rather than applying a second behavior to achieve it.
-- Property added pAction
-- Modified the mouseUp handler so that it has the "do pAction" line

-- 9/2/2001 Pranav Negandhi
-- Feature Dropdowns and closures are now animated
-- The dropdown speed can be set from the GPDL dialog.
-- Property added pInterval
-- Modified the mOpen and mClose handlers to accomodate
-- the animation and added a new mDelay handler that
-- provides a wait between screen refreshes.

-- Usage
-- Can be applied to graphic sprites only
-- A sprite can either be a #submenu or a #menuitem
-- #submenu any sprite which upon click opens the menu further
-- #menuitem any sprite which upon click performs a given action

-- pLevel stores the depth of the sprite from the top level menu
-- Top level menu is always 0
-- e.g.
-- File  (0)
-- >>New...  (1)
-- >>Open...  (1)
-- >>Preferences  (1)
-- >>>>User...  (2)
-- >>>>System...  (2)
-- >> Exit  (1)

-- pParent is the number of the sprite which when clicked
-- makes this sprite visible. pParent sprite is always a
-- submenu

property mySprite  -- Reference to the current sprite
property fOpen  -- Flag indicating whether the sprite displays its child
sprites or no
property fSiblingsChecked  -- Init done flag
property pType  -- The type of the node(#submenu, #menuitem)
property pLevel  -- The level of the node starting from 1 onwards
property pParent  -- The parent sprite of the current node
property mySiblings, myChildren  -- List of siblings and child sprites of
the current node
property pAction
property pInterval

on prepareFrame me
  -- mInit is put in prepareFrame instead of beginSprite
  -- because when beginSprite is invoked, higher numbered
  -- sprites are not ready yet and therefore not messaged.
  -- prepareFrame has no such problem.
  if NOT fSiblingsChecked then
    mInit me
  end if
end prepareFrame me

on mouseUp me
  if pType = #submenu then
    mToggleMenu me
  else
    sendSprite(pParent, #mCloseTree)
  end if

  do pAction
end mouseUp me

on mInit me
  mySprite = sprite(me.spriteNum)
  fOpen = FALSE
  pInterval = 0.01 * 60

  -- Build a list of all child and sibling sprites
  mySiblings = []
  myChildren = []
  repeat with i = 1 to the lastChannel
    if sendSprite(i, #mIsSibling, me.spriteNum, pParent) then
      mySiblings.add(i)
    end if
    if sendSprite(i, #mIsChild, me.spriteNum) then
      myChildren.add(i)
    end if
  end repeat

  repeat with i in myChildren
    sprite(i).visible = FALSE
  end repeat

  fSiblingsChecked = TRUE
end mInit me

on mToggleMenu me
  -- Toggles display of the current nodes children
  -- Also hides children of all sibling nodes
  fOpen = NOT fOpen
  if fOpen then
    mOpen me
  else
    repeat with i in myChildren
      sendSprite(i, #mClose)
    end repeat
    mClose me
  end if
end mToggleMenu me

on mOpen me
  --Hide all sibling sprites children
  fOpen = TRUE
  repeat with i in mySiblings
    sendSprite(i, #mClose)
  end repeat

  -- Makes all child sprites visible
  repeat with i in myChildren
    sprite(i).visible = TRUE
    updateStage
    mDelay me, pInterval
  end repeat
end mOpen me

on mClose me
  -- Hide the child sprites
  fOpen = FALSE
  repeat with i = myChildren.count down to 1
    vCurrSprite = myChildren[i]
    sendSprite(vCurrSprite, #mClose)
    sprite(vCurrSprite).visible = FALSE
    updateStage
    mDelay me, pInterval
  end repeat
end mClose me

on mCloseTree me
  -- Instructs the parent sprite to close all
  -- other sprites
  if pParent = 0 then
    repeat with i in myChildren
      sendSprite(i, #mClose)
    end repeat
    mClose me
  else
    sendSprite(pParent, #mCloseTree)
  end if
end mCloseTree me

on mIsSibling me, vSpritenum, vParent
  -- Finds out if the current sprite is a
  -- sibling
  if vSpritenum <> me.spriteNum then
    if vParent = pParent AND pType = #submenu then
      RETURN TRUE
    end if
  end if
end mIsSibling me

on mIsChild me, vSpritenum
  -- Finds if the current sprite is a child
  if vSpritenum = pParent then
    RETURN TRUE
  end if
end mIsChild me

on mDelay me, vInterval
  vTime = the timer
  repeat while the timer < vTime + vInterval
    nothing
  end repeat
end mDelay me

on getPropertyDescriptionList me
  Desc = []

  addProp Desc, #pType, [#default #menuitem, #format #symbol, #comment
"Menu type", #range [#submenu, #menuitem]]
  addProp Desc, #pParent, [#default 1, #format #integer, #comment "Menu
parent"]
  addProp Desc, #pAction, [#default "nothing", #format #string, #comment
"Lingo to execute on mouseUp"]
  addProp Desc, #pInterval, [#default 0.01, #format #float, #comment
"Dropdown refresh every n seconds", #range [#min 0, #max 0.09]]

  return Desc
end getPropertyDescriptionList me





<snip>
Unfortunately I was unable to open the file.  I received the following
error: "Movie HTAP cannot be loaded. The file version is too new"   I'm
still using version 7.0.2 on Windows 95.  Is there some way I can open it?


Is it possible to create menu items that have drop-down menus with
installMenu?  If so, could someone please point me in the right direction?
<snip>


Regards,
Pranav




[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