Table Of Contents
Graph IDE ► Examples ► Button
A button is a graphic that, when clicked, changes state and also sends a message to a target object so something can be done. Making a button and using a button is trivial and also an iconic computer science "homework assignment". In the 1980s I suggested using a button on an advanced test bed for a prototype military radar system being built by teams of PhD. researchers at a federal research center. The group leader told me that it was too risky and they preferred hardware toggle switches. That is not the case now and buttons are a good example of Graph IDE's Programming capabilities as well as a good example of how many ideas went from novel and risky to pedestrian.
The following figures shows some buttons.
The buttons shown above are stock buttons from a palette. They are made by making two graphics (in this case group graphics), placing them over each other and then grouping those graphics. The bottom graphic is the off state while the top graphic is the on state. Then the group is programming using the following script:
The Button class is built into Graph IDE, however with a modest amount of use of the Event Qualifier specifications you can make your own button class and way of making buttons respond to mouse clicks and hovers. The
registerWithName: line sends a message to the controller (see Container View) so that the button state (pointer aka: id) can be registered and the target and action set using the Button methods
setAction:. When the target is called upon it can retrieve the button state by calling the method
state upon it (which returns a BOOL type value).
The SineTable project shows the use of a button. This section is simply concerned with how to make a graphical element which meets the specifications of a button. With a little ingenuity it is not hard to figure out how to make a wide range of controls. In fact, a graph can be a control where it displays data and event qualifiers are used for feedback in order to control a process whose data is shown on the graph.