#include <button.h>
Inheritance diagram for KrToggleButton:
Public Member Functions | |
KrToggleButton (int width, int height, const KrScheme &scheme) | |
Creates a toggle button. | |
KrToggleButton (KrSprite *graphic, const KrScheme &scheme) | |
Creates a toggle button, and potentially a much better one. | |
virtual int | IsMouseListener () |
IsMouseListener returns whether this is a mouse listener or not, and which buttons are listened to. | |
virtual void | MouseIn (bool down, bool in) |
virtual void | MouseMove (bool down, int x, int y) |
virtual bool | MouseClick (int down, int x, int y) |
It also responds to hot keys.
The toggle button is selectable and can be accelerated.
Events Sent
There are 2 approaches to rendering a Button. The first is to let the system draw a square button, optionally with a text or icon. No graphics are required to be supplied, and this is a fast way to get started.
The second approach is to provied a 3 frame Sprite, where the frames represent the UP, OVER, and DOWN states.
Creates a toggle button, and potentially a much better one.
A 3 frame sprite must be provided. Frame 0: UP state, Frame 1: OVER state, and Frame 2: DOWN state. The scheme is only used for the text.
virtual int KrToggleButton::IsMouseListener | ( | ) | [inline, virtual] |
IsMouseListener returns whether this is a mouse listener or not, and which buttons are listened to.
A return value of 0 is no listening. Else it can return an OR mask of the buttons ( LEFT_MOUSE, RIGHT_MOUSE, MIDDLE_MOUSE ) it wants to listen for mouse clicks.
The simple case is to only listen to the left mouse, in which case return LEFT_MOUSE (1). The click messages can then be treated like a boolean for the left mouse (1 is down, 0 is up.)
Currently, with version 2.0, only the LEFT_MOUSE is supported.
MouseIn is called when a mouse moves in to the widget. The 'down' parameter reflects the state of the left mouse button. The 'in' reflects whether it is moving to the widget (true) or away from the widget (false).
MouseMove reports when the mouse moves over this widget.
MouseClick is called when the mouse is clicked on this widget. The 'click' param will have a single value (not OR mask) of LEFT_UP, LEFT_DOWN, RIGHT_UP, etc. with x and y coordinates of the action.
In the simple case that you are only listening to the left mouse, the parameter will be essentially a boolean: 1 for the left mouse down, 0 for the left mouse up.
Reimplemented from KrWidget.
virtual bool KrToggleButton::MouseClick | ( | int | down, | |
int | x, | |||
int | y | |||
) | [virtual] |
virtual void KrToggleButton::MouseIn | ( | bool | down, | |
bool | in | |||
) | [virtual] |
virtual void KrToggleButton::MouseMove | ( | bool | down, | |
int | x, | |||
int | y | |||
) | [virtual] |