Add functions IGUIButton::getClickShiftState and IGUIButton::getClickControlState to get shift/ctrl key-state when a button was clicked. Thanks @StarSonata for patch (long time ago...).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5545 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2017-10-19 21:00:50 +00:00
parent 06efc9a196
commit 4d59133e49
4 changed files with 31 additions and 0 deletions

View File

@ -1,6 +1,7 @@
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Add functions IGUIButton::getClickShiftState and IGUIButton::getClickControlState to get shift/ctrl key-state when a button was clicked. Thanks @StarSonata for patch.
- Add function ISceneManager::clearAllRegisteredNodesForRendering. - Add function ISceneManager::clearAllRegisteredNodesForRendering.
- Add function IVideoDriver::queryTextureFormat to allow checking if a driver supports textures with a specific color format. - Add function IVideoDriver::queryTextureFormat to allow checking if a driver supports textures with a specific color format.
- ISceneManager::getMesh can now creates meshes with alternative cache-names. - ISceneManager::getMesh can now creates meshes with alternative cache-names.

View File

@ -225,6 +225,14 @@ namespace gui
//! Checks whether the button scales the used images //! Checks whether the button scales the used images
virtual bool isScalingImage() const = 0; virtual bool isScalingImage() const = 0;
//! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event
/** Generated together with event, so info is available in the event-receiver. */
virtual bool getClickShiftState() const = 0;
//! Get if the control key was pressed in last EGET_BUTTON_CLICKED event
/** Generated together with event, so info is available in the event-receiver. */
virtual bool getClickControlState() const = 0;
}; };

View File

@ -22,6 +22,7 @@ CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
: IGUIButton(environment, parent, id, rectangle), : IGUIButton(environment, parent, id, rectangle),
SpriteBank(0), OverrideFont(0), SpriteBank(0), OverrideFont(0),
ClickTime(0), HoverTime(0), FocusTime(0), ClickTime(0), HoverTime(0), FocusTime(0),
ClickShiftState(false), ClickControlState(false),
IsPushButton(false), Pressed(false), IsPushButton(false), Pressed(false),
UseAlphaChannel(false), DrawBorder(true), ScaleImage(false) UseAlphaChannel(false), DrawBorder(true), ScaleImage(false)
{ {
@ -146,6 +147,9 @@ bool CGUIButton::OnEvent(const SEvent& event)
if (Parent) if (Parent)
{ {
ClickShiftState = event.KeyInput.Shift;
ClickControlState = event.KeyInput.Control;
SEvent newEvent; SEvent newEvent;
newEvent.EventType = EET_GUI_EVENT; newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this; newEvent.GUIEvent.Caller = this;
@ -205,6 +209,9 @@ bool CGUIButton::OnEvent(const SEvent& event)
if ((!IsPushButton && wasPressed && Parent) || if ((!IsPushButton && wasPressed && Parent) ||
(IsPushButton && wasPressed != Pressed)) (IsPushButton && wasPressed != Pressed))
{ {
ClickShiftState = event.MouseInput.Shift;
ClickControlState = event.MouseInput.Control;
SEvent newEvent; SEvent newEvent;
newEvent.EventType = EET_GUI_EVENT; newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this; newEvent.GUIEvent.Caller = this;

View File

@ -128,6 +128,18 @@ namespace gui
//! Checks whether the button scales the used images //! Checks whether the button scales the used images
virtual bool isScalingImage() const _IRR_OVERRIDE_; virtual bool isScalingImage() const _IRR_OVERRIDE_;
//! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event
virtual bool getClickShiftState() const _IRR_OVERRIDE_
{
return ClickShiftState;
}
//! Get if the control key was pressed in last EGET_BUTTON_CLICKED event
virtual bool getClickControlState() const _IRR_OVERRIDE_
{
return ClickControlState;
}
//! Writes attributes of the element. //! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_; virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const _IRR_OVERRIDE_;
@ -207,6 +219,9 @@ namespace gui
u32 ClickTime, HoverTime, FocusTime; u32 ClickTime, HoverTime, FocusTime;
bool ClickShiftState;
bool ClickControlState;
bool IsPushButton; bool IsPushButton;
bool Pressed; bool Pressed;
bool UseAlphaChannel; bool UseAlphaChannel;