Reference » Window classes » MButton

Elgrint::MButton class

Declared in WCButton.h


Two-state selector, which can be pushed or released.


Base class: MWindow


Name Description
BorderColor The color of the button's 1-pixel wide border.
Chosen If true, the button is drawn more prominently, indicating its special status, e.g. default dialog button.
ChosenMarkColor If Chosen is true, this color is used to make the button more prominent.
Icon Image displayed in the button instead of Text.
Text Text for the button - displayed inside the button if Icon is empty, or in MInfoLabel otherwise.


Name Description
MButton(parent,rect,nidReleased,text,icon) Standard-form constructor. Creates and opens a new button window.


Name Description
setPushed(val) Puts the button into a pushed (true) or released (false) state.


Name Description
isPushed() Returns the current pushed/released state of the button.


Name Description

Show info label on hovering, if both Text and Icon are not empty.


Repaint, release on focus loss (without notice).


Repaint, release on hot loss (without notice), and reset info label blocking.


Switch state, generate "Pushed" and/or "Released" events.


Draw button in proper state




Emulates mouse click repeats (timer 1000) and hovering (timer 1001).


The command button (or simply button) is the simplest of all selectors. Basically, it provides a selection out of just two values, called the pushed and released states. A pushed button appears darker and slightly shifted compared to the released button.

A button can be pushed and released using the kbClick1, kbSpace, or kbEnter keys with any combination of modifiers (e.g. Ctrl+Shift+Alt+Space is treated just like Space). It can also be pushed and released programmatically, using setPushed function. The isPushed revealer returns the current state of the button.

A button can contain text (defined with Text property) or icon (defined with Icon property). If both properties are non-empty, then the icon is displayed inside the button, and the text appears on cursor hovering (after 0.5 seconds) next to the button, using MInfoLabel child window. If icon is empty, then the text is displayed inside the button (no info label in this case). The rest of the button's properties control the button's visual appearance and are not very important.

The button can generate two notices: "Pushed" and "Released". "Released" is generated only when the button is released, and it's the preferred notice (specified in constructor). "Pushed" is generated when the button is pushed, and in regular intervals after that (determined by MSys::getFirstRepeatDelay and MSys::getRepeatDelay functions) until the button is released. That being said, if the clicked button loses the hot state (see HotChanged), or if the pushed button loses focus, e.g. by pressing kbEsc (see FocusChanged), the button is released without generating any notice. This allows the user to prevent the "Release" event if the button was pushed by mistake.

The button uses two timers: 1000 controls the repeated push emulation, and 1001 – the cursor hovering emulation. This fact can be used to customize either operation by overloading OnTimerExpired (see TimerExpired).


Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.