IGUIEnvironment::hasFocus has now a parameter checkSubElements as subelements are usually seen as part of an element. Default unfortunately must be false due to backward compatibility.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4465 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2013-03-05 12:32:54 +00:00
parent 2659619e1a
commit 695abde41d
5 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,7 @@
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- IGUIEnvironment::hasFocus has now a parameter checkSubElements as subelements are usually seen as part of an element. Default unfortunately must be false due to backward compatibility.
- Add IGUIElement::isTrulyVisible which works like ISceneNode::isTrulyVisible and checks for parent visibility as well. - Add IGUIElement::isTrulyVisible which works like ISceneNode::isTrulyVisible and checks for parent visibility as well.
- Improved DDS loader and added support for DXTn (DXT1-5) compressed textures in OpenGL and Direct3D9 drivers. - Improved DDS loader and added support for DXTn (DXT1-5) compressed textures in OpenGL and Direct3D9 drivers.
- Add function ISceneNode::getTransformedBoundingBoxEdges. - Add function ISceneNode::getTransformedBoundingBoxEdges.

View File

@ -103,8 +103,9 @@ public:
//! Returns whether the element has focus //! Returns whether the element has focus
/** \param element Pointer to the element which is tested. /** \param element Pointer to the element which is tested.
\param checkSubElements When true and focus is on a sub-element of element then it will still count as focused and return true
\return True if the element has focus, else false. */ \return True if the element has focus, else false. */
virtual bool hasFocus(IGUIElement* element) const = 0; virtual bool hasFocus(IGUIElement* element, bool checkSubElements=false) const = 0;
//! Returns the current video driver. //! Returns the current video driver.
/** \return Pointer to the video driver. */ /** \return Pointer to the video driver. */

View File

@ -175,8 +175,8 @@ bool CGUIButton::OnEvent(const SEvent& event)
if (Environment->hasFocus(this) && if (Environment->hasFocus(this) &&
!AbsoluteClippingRect.isPointInside(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y))) !AbsoluteClippingRect.isPointInside(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y)))
{ {
Environment->removeFocus(this); Environment->removeFocus(this);
return false; return false;
} }
if (!IsPushButton) if (!IsPushButton)

View File

@ -329,11 +329,24 @@ bool CGUIEnvironment::removeFocus(IGUIElement* element)
} }
//! Returns if the element has focus //! Returns whether the element has focus
bool CGUIEnvironment::hasFocus(IGUIElement* element) const bool CGUIEnvironment::hasFocus(IGUIElement* element, bool checkSubElements) const
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return (element == Focus); if (element == Focus)
return true;
if ( !checkSubElements || !element )
return false;
IGUIElement* f = Focus;
while ( f && f->isSubElement() )
{
f = f->getParent();
if ( f == element )
return true;
}
return false;
} }

View File

@ -187,7 +187,7 @@ public:
virtual bool removeFocus(IGUIElement* element); virtual bool removeFocus(IGUIElement* element);
//! Returns if the element has focus //! Returns if the element has focus
virtual bool hasFocus(IGUIElement* element) const; virtual bool hasFocus(IGUIElement* element, bool checkSubElements=false) const;
//! Returns the element with the focus //! Returns the element with the focus
virtual IGUIElement* getFocus() const; virtual IGUIElement* getFocus() const;