VertClickBar and HoriScroll Demo with Documentation
Including Documentation for abstract class ClickBar

This page a demo of using both a VertClickBar and a HoriClickBar and includes documentation for VertClickBar, HoriClickBar and the abstract ClickBar class that both share. The only difference between the vertical and horizontal ClickBar is their constructors. Notice that the constructors for all three classes have the same parameter list.

You may have to wait a minute for the sketch to load. Functionally, a ClickBar is similar to a ScrollBar but one clicks the bar instead of dragging the scroll button. There are two advantages. 1. It will normally work on a touch screen. Touch generally pass taps on to the application but capture dragging operations. 2. They are easier to code.

Display sketch code: ClickBarDemo.pde

In the demo, if you click either scroll bar, the other bar will be adjusted as well to complete the conversation. The demo shows a vertical ClickBar (VertClickBar) with optional hashmarks and value specified in the setup() method. A horizontal ClickBar (HoriClickBar) with optional labels and value specified in setup(). To illustrate that it is possible to reverse a ClickBar, the minimum and maximum values in the horizontal ClickBar have been reversed.

class VertClickBar
extends ClickBar
which extends ClickableMeter
which extends ClickablePanel
which extends Clickable

VertClickBar is a simple extension of the abstract class ClickBar.

** class VertClickBar( int leftX, int topY, int theWidth, int theHeight,
                    String theLabel, color stdColor, color overColor, color barColor,
                    float minValue, float value, float maxValue)
- Creates a vertical "ClickBar" given the upper left corner, the width and height, a label (not shown), the three colors, and the minimum, current, and maximum values. Reversing theMinimum and theMaximum just reverses the orientation of the bar so that the minimum is on the top. (width < height is required.)

Return to top of page

class HoriClickBar
extends ClickBar
which extends ClickableMeter
which extends ClickablePanel
which extends Clickable

HoriClickBar is a simple extension of the abstract class ClickBar.

** class HoriClickBar( int leftX, int topY, int theWidth, int theHeight,
                    String theLabel, color stdColor, color overColor, color barColor,
                    float minValue, float value, float maxValue)
- Creates a horizontall "ClickBar" given the upper left corner, the width and height, a label (not shown), the three colors, and the minimum, current, and maximum values. Reversing theMinimum and theMaximum just reverses the orientation of the bar so that the minimum is on the right. (width > height is required.)

Return to top of page

abstract class ClickBar
extends ClickableMeter
which extends ClickablePanel
which extends Clickable

This method not be used directly by the user program. It can only be used by VertClickBar or HoriClickBar.

The constructor's parameter list is the same as VertClickBar, HoriClickBar, and ClickableMeter's list.

Additional fields

static final int ITEM_HEIGHT = 20 - Used for the width or height of the buttons at the end of the scroll bar.
Button downBtn, upBtn - The button at the bottom (or left) and the button at top (or right) of the scroll bar.
int topDownBtn - The location of the down botton.
int leftUpBtn - The location of the upButton.
# abstract class ClickBar( int leftX, int topY, int theWidth, int theHeight,
                    String theLabel, color stdColor, color overColor, color barColor,
                    float minValue, float value, float maxValue)
- Completes a vertical or horizontal "ClickBar" given the upper left corner, the width and height, a label (not shown), the three colors, and the minimum, current, and maximum values. Reversing theMinimum and theMaximum just reverses the orientation of the bar.

Note: in this constructor, fields x, y, w, and h and the parameters leftX, topY, theWidth and theHeight all refer to the panel between the buttons at its ends, not the total size of the bar including up and down buttons. Thus the meaning of this constructor parameters are a little different than the meaning of the VertClickBar and HoriClickBar constructors' parameters.
** void setVisible(boolean b)
- Sets the ClickBar and all its parts as being visible true or false.
** void setEnabled(boolean b)
- Sets the ClickBar and all its parts as being enabled true or false.
* void display()
- Draws the complete ClickBar including the up and down buttons and any hashmarks, labels and values that have been specified. The bar may be vertical or horizontal.
boolean isOver()
- Determines if any part of the ClickBar has been clicked and returns true if so. Always returns false if stillSearching_ is false.
boolean checkForClick)
- Checks to see if any part of the "ClickBar" has been clicked. If so, it updates the current "value" and sets "clicked" to true and then returns true. It can only be called directly or indirectly in the mouseReleased() method.
** boolean hasBeenClicked()
- Determine if the ClickBar has been clicked. If so, it returns true after "clicked" is set to false. It must be called directly or indirectly in the draw() method.
** void setScrollable(boolean canScroll)
- Used to specify if the ClickBar (and all its parts) is scrollable.

Method use codes:

** This constructor or method is designed to be called in the user sketch.

* This method is normally not called in the user's sketch unless the Clickable item was not been included in a ClickableGroup. ClickableGroup automatically uses the method as needed. Exception: This method may be needed if the user is extending Clickable with a new class.

# This constructor or method is rarely used in the user program. In Java, it would probably marked "private". Clickable, ScrollBar, and some other abstract constructors would never be called directly by the user sketch because they do nothing useful unless the user is extending a class.

Return to top of page