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
Rolling a Ball.
ADOXtra
Export to Pocket PC Xtra
DOMAJ Site and Forum
Composite Images with Alpha
Drag sprite around a snap grid
A* Pathfinder in Lingo
Dave's 3D engine V7.1
Confine Effect ot Mouse Over-Alphamania
NAB - 'Not Another Button'
 

 

 

Behavior Tool Tips/Help popUp box ver 2.1

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: JohnKanding (website)

This is a help-behavior to use with buttons and fields To toggle the help on/off just use "sendAllSprites(#mToggleHelp)" The help needs a simple text-field to show the helptext over the button or field.

--Create a field and put it in a sprite channel
--Set the slider to the sprite channel you chosed, at TEXT-FIELD SPRITE NO:
--in the behavior panel.
--Name the text field anything you like, but write the name chosen in the THE NAME OF THE TEXT FILED box in the behavior panel.
--If you like, create a button or whatever and use
--On mouseUp
--  sendAllSprites(#mToggleHelp)
--end
--This will turn all helpboxes on or off
property pHelpOn           -- true/false; help on/off
property pHelpText         -- the help-txt to show
property pWidth            -- the width of the help-text field
property pHeight           -- the height of the help-text field
property pSprite           -- the spriteNum
property pMouse            -- The mouse loc
property pHelpSprite       -- the spriteNum of the help-text field
property pForeColor        -- the forecolor of the help-text field
property pBackColor        -- the backcolor of the help-text field
property pHasShadow        -- set the boxDropShadow to TRUE or FALSE
property pHelpNam          -- the name of the help-text field
property pCastLib          -- the active castLib of the member
property pHelpCastLib      -- the active castLib of the help-text field
property pStageWidth       -- the width of the stage
property pStageHeight      -- the height of the stage
property pHelpDelay        -- the delay before popUp (in ticks)

on beginSprite me
  set pSprite = the spriteNum of me
  set pHelpCastLib = the castLibNum of sprite pHelpSprite
  set pHelpNam = the name of member (the memberNum of sprite pHelpSprite)of castlib pHelpCastLib
  set pCastLib = the castLibNum of sprite pSprite
  set pWidth = the width of member pHelpNam of castlib pHelpCastLib
  set pHeight = the height of member pHelpNam of castlib pHelpCastLib
  put "Back to controlroom" into member pHelpNam of castlib pHelpCastLib
  set the font of member pHelpNam of castlib pHelpCastLib to "Courier"
  set the fontSize of member pHelpNam of castlib pHelpCastLib to 10
  set the border of member pHelpNam of castlib pHelpCastLib to 1
  set pStageWidth = (the stageRight - the stageLeft)
  set pStageHeight = (the stageBottom - the stageTop)
  puppetSprite pHelpSprite,TRUE
  set the wordWrap of member pHelpNam of castlib pHelpCastLib to False
  set the visible of sprite pHelpSprite to FALSE
  set the ink of sprite pHelpSprite to 0
end beginSprite

on mouseEnter me
  mOpenHelp(me)
  set pMouse to the MouseH
  startTimer -- This is for the pHelpDelay test
  pass
end

on mouseWithin me
  if the timer > pHelpDelay and the timer < pHelpDelay + 20 then
    mShowHelp(me)
  end if
  pass
end mouseWithin

on mouseLeave me
  mCloseHelp(me)
  pass
end

on mOpenHelp me
  if pHelpOn then
    set the text of member pHelpNam of castlib pHelpCastLib to pHelpText
    set the visible of sprite pHelpSprite to FALSE
  end if
end

on mShowHelp me
  if pHelpOn then
    put the number of chars in field pHelpNam of castlib pHelpCastLib into length
    put (length+0.5)*9 into modLength -- This is to get a pseudo length of the chars
    set the foreColor of member pHelpNam of castlib pHelpCastLib to pForeColor
    set the BackColor of member pHelpNam of castlib pHelpCastLib to pBackColor  
    
    if pHasShadow then
      set the boxDropShadow of member pHelpNam of castlib pHelpCastLib to 4
    else
      set the boxDropShadow of member pHelpNam of castlib pHelpCastLib to 0
    end if
    set the rect of member pHelpNam to rect(0,0,modLength,15)
    put (the right of sprite pHelpSprite - the left of sprite pHelpSprite) into SprLength --How long is the field
    set the locH of sprite pHelpSprite to pMouse-(modLength/2) -- Where is the middle?
    set the locV of sprite pHelpSprite to the bottom of sprite pSprite+5 --Put it a little bit lower
    
    --Is the helpbox near the right edge of the stage?
    if the locH of sprite pHelpSprite + SprLength > pStageWidth then
      set the locH of sprite pHelpSprite to  pStageWidth - SprLength -- You canīt set the right of sprite so we do it this way
    end if
    
    --Is the helpbox near the left edge of the stage?
    if the locH of sprite pHelpSprite  <= 0 then
      set the locH of sprite pHelpSprite to 0
    end if
    
    --Is the helpbox near the bottom of the stage
    if the locV of sprite pHelpSprite+pHeight > pStageHeight then
      
      set the locV of sprite pHelpSprite to pStageHeight - (the Height of sprite pSprite + (pHeight*2))
    end if
    
    
    set the visible of sprite pHelpSprite to FALSE -- donīt show up until it has "moved" to the right spot
  end if
  set the visible of sprite pHelpSprite to TRUE -- show
end mShowHelp

on mCloseHelp me
  if pHelpOn then
    set the visible of sprite pHelpSprite to FALSE
    set the locH of sprite pHelpSprite to 600
    set the locV of sprite pHelpSprite to 600
  end if
end mCloseHelp

on mKillHelp me
  mCloseHelp(me)
  set pHelpOn = FALSE
end mKillHelp

on mToggleHelp me
  mCloseHelp(me)
  if pHelpOn then
    set pHelpOn = FALSE
  else
    set pHelpOn = TRUE
  end if
end mToggleHelp

on getPropertyDescriptionList
  set p_list = [:]
  set p_list = [#pHelpSprite: [ #comment:"Text-field sprite no:",#format:#integer, #default:100, #range:[#min:1,#max:120]],#pHelpText: [ #comment:"The text to show:",#format:#string, #default:"No help available"], #pForeColor: [ #comment:"The textcolor:",#format:#integer, #default:255, #range:[#min:0,#max:255]], #pBackColor: [ #comment:"The backcolor:",#format:#integer, #default:0, #range:[#min:0,#max:255]], pHasShadow: [ #comment:"Shadow on:",#format:#boolean, #default:FALSE], #pHelpNam: [#comment:"The name of the text-field:",#format:#string, #default:"helptxt"],#pHelpOn: [ #comment:"Help on/off",#format:#boolean, #default:TRUE]]
  return p_list  
end getPropertyDescriptionList

on getBehaviorDescription
              return "This is a help-behavior to use with buttons and fields"& RETURN & "To toggle the help on/off just use" & "'sendAllSprites(#mToggleHelp)'" & RETURN & "The help needs a simple text-field to show" & "the helptext over" & RETURN & "the button or field." & RETURN &"Code by Detlef Beyer (d.beyer@hermes.de)& RETURN and John Kanding (johnkanding@vip.cybercity.dk)"
            end getBehaviorDescription

 


Contact

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

Send e-mail