cegui根据一个位置获得窗体

不是很多,但是偶尔会遇到这种需求:传入一个Windows窗口的位置,然后返回一个该位置上可以点到的控件。。

第一次找到的了CEGUI::System下的

Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;

但是他是私有..

看看实现就知道其实还是通过Window::getTargetChildAtPosition得到的~看看这个函数的实现,是迭代的过程~那么调用根窗体的这个方法应该可以得到~

System中不过做了一个全局的考虑~比如CaptureWindow和ModalTarget,ModalTarget应该就是独占窗体吧。。。

有意思的是Window::getTargetChildAtPosition如何能正确得到哪个孩子在上还是在下。。

秘密在这:

Window* Window::getTargetChildAtPosition(const Vector2& position,
                                         const bool allow_disabled) const
{
    const ChildList::const_reverse_iterator end = d_drawList.rend();

...

}

 

    //! Child window objects arranged in rendering order.
    ChildList d_drawList;

 

后绘在上...

..........................................


 /*!
 /brief
  Return the Window object that the mouse is presently within

 /return
  Pointer to the Window object that currently contains the mouse cursor, or NULL if none.
 */
 Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}

你可能感兴趣的:(cegui根据一个位置获得窗体)