Package Things :: Module Thinglets :: Class ButtonThing
[frames] | no frames]

Class ButtonThing

       object --+            
                |            
timeline.Timeline --+        
                    |        
   ThingObjects.Thing --+    
                        |    
    ThingObjects.HitThing --+
                            |
                           ButtonThing

A ButtonThing is a simple way to create "buttons" where you have four states: 1) Normal, 2) Over, 3) Down and 4) Up.

See the addStates() method for more information.

HitArea

Implement the usual drawHitarea() method to define the hit area.

Events

You can implement these event methods:

  1. onButtonOver()
  2. onButtonOut()
  3. onButtonDown()
  4. onButtonUp()
Instance Methods
 
__init__(self, id='ButtonThing')
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
keys(self, keystring, *stuff)
NOTE: A ButtonThing can't have keys.
 
addStates(self, statedict=None)
Use, in your ButtonThing class: self.addStates( {"normal":A1,"over":A2,"down":A3,"up":A4} ) (where A1, A2, A3 and A4 are all Things of some kind) If you supply a dict, you *must* supply all those keys.
 
onEnter(self, x, y)
 
onLeave(self, x, y)
 
onDown(self, x, y)
 
onRelease(self)

Inherited from ThingObjects.Thing: __len__, changeLayer, changeProps, funcs, getProps, goPlay, goStop, jumps, labels, loop, nextFrame, play, showData, stop, stops, toTop

Inherited from timeline.Timeline: add

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables

Inherited from ThingObjects.Thing: currentFrame, frame, globalProps, lifespan

Inherited from timeline.Timeline: parentThing

Properties

Inherited from object: __class__

Method Details

__init__(self, id='ButtonThing')
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • id - A string to identify this Thing. It's mainly for debug purposes, but handy within your own code too.
Overrides: object.__init__
(inherited documentation)

keys(self, keystring, *stuff)

 

NOTE: A ButtonThing can't have keys. Put it into another Thing in order to manipulate its position etc.

Parameters:
  • keystring - A string that represents the keyframes, blanks and tweens of this Thing. This string dictates where/when children of this Thing will appear.
  • stuff - Any number of Props() objects. Have as many as you have keyframes.
Overrides: ThingObjects.Thing.keys

addStates(self, statedict=None)

 

Use, in your ButtonThing class: self.addStates( {"normal":A1,"over":A2,"down":A3,"up":A4} ) (where A1, A2, A3 and A4 are all Things of some kind) If you supply a dict, you *must* supply all those keys. If not, a stock button will be made.