Articles Archive
Articles Search
Director Wiki
 

Modifying a behavior's property dialog box

October 12, 1998
by Pat McClellan

Dear Multimedia Handyman,

I'm creating a behavior to control the bounce of a ball, using gravity. I don't really need help with the physics stuff, but I've got a question about the best way to do the getPropertyDescriptionList handler. I want it so that when you drop the behavior on a sprite, the author can pull down a list of planets to choose from. The problem is that there is no format #planet that I can specify in the handler.

Cosmo

Dear Cosmo,

You're absolutely right... the engineers at Macromedia were clearly derelict in their duties when they failed to build the #planet format into Director! But, fear not, you can create your own... sort of.

On page 154 of the Lingo dictionary, there's a table which lists all of the available formats for a property. For your convenience, here they are:

#integer #float #string #symbol #member #bitmap #filmloop #field #palette #picture #sound #button #shape #movie #digitalvideo #script #richtext #ole #transition #xtra #frame #marker #ink #boolean #cursor #graphic

Not a celestrial body in the group! These formats make it possible for you to have a pulldown list in the getPropertyDescriptionList (gpdl) dialog box. Quite convenient. A great example of this is if you specify that a property is a #cursor, then a pulldown list of all available cursors appears.

Now, what we'll be doing is not really creating a new format, but rather, defining a "range". Range is an optional value which can be included when setting up a property in the gpdl handler. I'll assume that elsewhere in your behavior, you'll be correlating which planet to the appropriate level of gravity, so I won't deal with that. All I'm focusing on is letting the author assign a planet value to the pWhichPlanet property.

The planets can be represented by symbols, such as #Mercury, #Venus, etc. So actually, the format that we specify will be #symbol. We'll create a list of all these symbols and then use the list to define the range for the property. Here's the code:


property pWhichPlanet 
on getPropertyDescriptionList me
  set planet = [#Mercury, #Venus, #Earth, #Mars, ¬
    #Jupiter, #Saturn, #Uranus, #Neptune, #Pluto] 
  set pdlist to [:]
  addprop pdlist, #pWhichPlanet, [#comment:"Which ¬
    planet?", #format:#symbol, #default:#earth, ¬
    #range: planet]
  return pdlist
end getPropertyDescriptionList

And here's the result:

Good luck with your project, and be sure to contribute your custom behavior to the Lingo Behavior Database, which is linked to our Resources section!

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.