Bambookit Home    Bambookit GUI Tutorial

Back    Next   

III. Event-Handling

Chapter 11. Events




Key Pressed


Method signature

addActionTarget = "[String] widget name, [Constant] event,[Method] execute method"
[String] is the name of the widget
[Constant] the event to listen on
[Method] the method signature



Examples

A key pressed event occurs when a key on the keyboard is pressed.


To demostrate the keypressed event we will create a popup on a keypressed event, and a popdown on a keyreleased event



<Widget setShape="0,0,100,80">
<Widget setShape="10,10,80,25" setLabel="Popup" setName="popup" setBorder="flat" setVisible="false"/>
<Button setShape="10,40,80,25" setLabel="Push Me" setName="pushme" addActionTarget="popup,keypressed,setVisible='true',popup,keyreleased,setVisible='false'"/>
</Widget>

The Widget, 'popup', will execute the method 'setVisible' (if you press any key on the keybord, but first make sure the button has focus.)
On the keypressed event we execute popup.setVisible="true", the Widget Pops up
On the keyreleased event we execute popup.setVisible="false", the Widget Pops down
To handle more than one event, we append them to the addActionTarget, the addActionTarget accepts parameters in tuples (3,6,9,etc...)



Back    Next