MenuBar Demo and Documentation

Display sketch code: MenuDemo.pde. The code for MenuBar is in Clickable.pde

The demo is the same as Menu's as the MenuBar is used in conjunction with Menus. MenuBar extends Clickable only so that it can be included in a ClickableGroup. It does not respond to clicks.

The MenuBar must be created before any Menus are created because Menus get information from the MenuBar while they are being created. Moreover, it must be included in the array used to form the ClickableGroup before the first Menu is included. This is required because Menus are must be drawn on top of the MenuBar.

class MenuBar
extends Clickable

Menu items are placed on the top of sketch on the MenuBar. The MenuBar must be created before the first Menu item because it supplies color and location information to the Menu item during its construction. It must be included in the ClickableGroup before the first Menu item. The bar does not scroll. The user program must allow 20 pixels at the top of sketch for the bar when it used.

Fields

int nextX - The x value for the next Menu item. It is updated every time a Menu is created.
color menuC - The color of the MenuBar itself and the color it supplies for Menu buttons when they are created.
color overMenuC - The color provided to Menus as their "over" color. It is not used by the MenuBar itself because the bar does not respond to mouse overs.
** MenuBar(color stdColor, color overColor)
- Constructs a MenuBar which placed at the top of the sketch. It supplies color and location information to menus placed on the bar. The bar is 20 pixels high.
* void display()
- Draws the menu bar across the top of the sketch window. Menus will be drawn on top of this bar. Hence, the MenuBar must be included in the ClickableGroup before the first Menu.
# int xLocation(int itsWidth)
- When called by a Menu constructor it supplies the x value for that menu. It then updates the internal value of nextX by the value of "itsWidth".
# color getColor()
- Returns the standard menu color when called by a Menu constructor.
# color getOverColor()
- Returns the "over" menu color used by a Menu when the cursor is over the menu or its pull down list. This is done automatically when called by a Menu constructor.

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.


Inherited from Clickable

Fields
NOTHING_CLICKED, COMBO_BUTTON, DISABLED_COLOR, borderColor, c, clicked, clickedItemNum, colorState, enabled, h, label, over, overC, scrollable, selected, selectedItemNum, visible, w, x, y

Constructors
Clickable

Methods
checkForClick, display, doNotSelect, getClickedItemNum, getColorState, getH, getItem, getLabel, getSelected, getSelectedItem, getSelectedItemLabel, getSelectedItemNum, getW, getX, getY, hasBeenClicked, hideSomething, isOver, setBorderColor, setColorState, setH, setLabel, setScrollable, setSelected, setSelectedItemNum, setEnabled, setVisible, setW, setX, setY, sX, sY

Return to the top of the page

Revised: 04/11/2014