Syntax:
find event in {component}
Keyword handler:
net.eclecity.linguist.graphics.keyword.GraphicsKFind.class
Runtime handler(s):
net.eclecity.linguist.graphics.handler.GraphicsHFindEvent.class
Function:
Find an event. The mechanism by which events - button clicks, mouse in/out/move events, key presses etc - are handled is by callbacks. A callback is registered using the on instruction, which states what should happen when the specified event occurs.
Where you have a number of components of a type all performing a similar task it is most efficient to use an array variable to hold them. So for example you might have an array of ten buttons to represent a numeric keypad. To avoid the need for ten callback routines you can aim each of the event handlers at the same callback. When the event occurs, the find instruction will index the array to the element that triggered the event. Here's what it looks like:
button Numbers 10 variable N variable X variable Y . . put 100 into X put 100 into Y put 0 into N while N is less than 10 begin index Numbers to N create Numbers in MyWindow title N at X Y on Numbers go to NumbersCB add 50 to X add 1 to N end stop NumbersCB: find event in Numbers put the index of Numbers into N ...
The main part of the listing creates a set of buttons numbered 0 through 9 in a single horizontal strip. When any button is clicked the program will start at NumbersCB, which finds which button was the cause of the event and transfers its index to N for subsequent processing.
Example(s):
find event in Buttons