onMouseLeaves when window destoryed

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

yuchting
Just popping in
Just popping in
Posts: 2
Joined: Thu Nov 20, 2008 11:14

onMouseLeaves when window destoryed

Postby yuchting » Tue Apr 06, 2010 06:26

Hi~
In our project with CEGUI, the windows' prompt(window) is showing when onMouseEnters and disappear when onMouseLeaves,because the CEGUI's tool tips is too weak for us.But CEGUI system haven't called onMouseLeaves when window destroyed ,so that our prompt window always show.

Do anyone had any idea that calling onMouseLeaves when window's destoryed in long CEGUI development journey, or has some special problem our haven't considered?

Thanks great GUI system.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: onMouseLeaves when window destoryed

Postby Jamarr » Tue Apr 06, 2010 16:19

I can see how this could be a problem. However, technically speaking the mouse is not leaving the window; I'm not sure that CE would add this feature just because it is convenient.

In any case, you can implement this yourself by subscribing to the global event for window destruction and fireing the mouse-leaves event yourself. Ex (this is only pseudo code):

Code: Select all

...
CEGUI::GlobalEventSet::getSingleton().subscribeEvent( "Window/DestructStart", &windowDestructHandler );
...
bool windowDestructHandler (const CEGUI::EventArgs& e)
{
    const CEGUI::Window* wnd = static_cast<const CEGUI::MouseEventArgs&>(e).window;
    window.fireEvent(Window::EventMouseLeaves, MouseEventArgs(&window));
    return true;
}
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

yuchting
Just popping in
Just popping in
Posts: 2
Joined: Thu Nov 20, 2008 11:14

Re: onMouseLeaves when window destoryed

Postby yuchting » Wed Apr 07, 2010 04:12

Thanks for reminding.

we just change the source code of CE directly :

Code: Select all

void Window::destroy(void)
{
    // because we know that people do not read the API ref properly,
    // here is some protection to ensure that WindowManager does the
    // destruction and not anyone else.
    WindowManager& wmgr = WindowManager::getSingleton();

 //  .....

    releaseInput();

   if(System::getSingleton().getWindowContainingMouse() == this){
      // in our project the prompt window disappearing will be injected in
      // mouse leaves event , so will inject this event before window destroyed
      //
      System::getSingleton().injectMouseLeaves();
   }

 //  .....
   
}

:cry: forgive my poor English

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: onMouseLeaves when window destoryed

Postby CrazyEddie » Wed Apr 07, 2010 09:30

Calling injectMouseLeaves is not correct here. This is used to inform CEGUI that the mouse has left the host window (i.e. the window provided by your operating system or window manager toolkit). The correct thing would be to listen for destruction events as Jamarr suggested, or if you want to modify the code, just call Window::onMouseLeaves instead.

CE


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests