Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mouse cursor enter/leave  (Read 13349 times)

0 Members and 1 Guest are viewing this topic.

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« on: June 14, 2008, 11:35:11 am »
It seems there isn't any event for the mouse cursor entering/leaving the window (in windowed mode).
Is there another way to detect this?
Or should I post this in feature requests?
I'm using CEGUI and having such notification would be nice (not required).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #1 on: June 14, 2008, 12:32:19 pm »
I can't see any situation where this event would be useful, even more for an internal GUI. Can you tell me what you (or CEGUI) would use it for ?
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #2 on: June 14, 2008, 01:14:33 pm »
Well to quote the cegui wiki:
Quote

 bool injectMouseLeaves( void )

This function informs CEGUI that the mouse cursor has left the system application window which CEGUI considers it's rendering area. This is useful if running in windowed mode to inform widgets that the mouse has actually left the CEGUI display completely (otherwise it may not get to know, since under some systems no more mouse events are generated for a OS window once the mouse has left it).

But the real reason I wanted this feature:
When dragging a CEGUI window around, if the mouse leaves the application window, the CEGUI window still acts as if the mouse button is held down (though it may not be) and the window is being dragged.
In other words, you can drag a window until the mouse is outside of the application, release the mouse button, then bring the mouse back in on the opposite side of the application and the window will 'jump' there and still drag around until you press+release the mouse button.

If I could be notified that the mouse left the application window then I'm sure I could find a way to inform CEGUI that the window is no longer being dragged.
There may be a way around this but I haven't been able to find any yet.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #3 on: June 14, 2008, 01:35:38 pm »
Ok, I see. I need to check how to implement this on every OS.
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #4 on: June 14, 2008, 01:50:46 pm »
Great, thanks!
No rush, it's not exactly a high priority thing.

And thanks for SFML, I'm glad I switched from HGE.  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #5 on: June 14, 2008, 02:49:46 pm »
Quote
I'm glad I switched from HGE

Interesting :)
As far as I know HGE is a more complete game engine, why did you switch ?
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #6 on: June 14, 2008, 03:43:46 pm »
The main reason is that SFML is cross-platform (yay!).
Another reason is that the HGE community seems to be pretty dead.
Lastly, I like SFML's code (interface+implementation) more than HGEs.
It seems well thought-out.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #7 on: June 14, 2008, 04:52:41 pm »
Ok I see. Thanks a lot for your feedback ;)
Laurent Gomila - SFML developer

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Mouse cursor enter/leave
« Reply #8 on: June 16, 2008, 02:52:45 am »
I'll second this as a (hopefully) easy-to-implement feature I'd like to see, for the same reason.  (I'm using CEGUI as well and have the same issue.)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #9 on: June 16, 2008, 03:12:37 am »
Yep, it should be implemented soon after the 1.3 release ;)
Laurent Gomila - SFML developer

Caspin

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - j_nick_terry@hotmail.com
    • View Profile
sfml gui
« Reply #10 on: June 18, 2008, 04:22:14 pm »
I"ve been planning (dreading) to implement my own gui system for my current game.  It's had to more than simple as a level editor is integrated with the game.
A friend of mine recently point me to cegui.  I don't know how I missed this gem.  I was wonder how difficult it was to get cegui to work with sfml.

Did you write an SFML renderer?

Are you using the standard OpenGL renderer and having sfml to preserve it's state?

Did you run into any snags?

In effect I'm looking for a tutorial on how you chose to bring up cegui with sfml.

-caspin

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #11 on: June 21, 2008, 05:04:03 am »
Using CEGUI in SFML is easy, you just use CEGUI::OpenGLRenderer.
Here's a screenshot:
http://i107.photobucket.com/albums/m300/silentdae/sfmlCEGUI.jpg
The tutorials on the CEGUI website apply to SFML as well.
http://www.cegui.org.uk/wiki/index.php/Tutorials

Here's a quick introduction though:
This part isn't SFML specific.
If you haven't already, download the SDK.
You may need to copy CEGUI-SDK\RendererModules\OpenGLGUIRenderer\*.h to CEGUI-SDK\include.

If you're not linking to the static CEGUI libs, you'll want to copy some DLLs to your app folder:
CEGUIBase.dll
CEGUIDevILImageCodec.dll
CEGUIExpatParser.dll
CEGUIFalagardWRBase.dll
CEGUISILLYImageCodec.dll
OpenGLGUIRenderer.dll
SILLY.dll

Plus the debug (CEGUIBase_d.dll, etc) versions as well.
The code from the screenshot was:
Code: [Select]

CEGUI::OpenGLRenderer* CEGUIRenderer = new OpenGLRenderer(0);
CEGUI::System* CEGUISystem = new System(CEGUIRenderer);
CEGUI::Window* RootWindow;

SchemeManager::getSingleton().loadScheme("WindowsLook.scheme");
FontManager::getSingleton().createFont("DejaVuSans-10.font");

CEGUISystem->setDefaultMouseCursor("WindowsLook", "MouseArrow");
CEGUISystem->setDefaultTooltip("WindowsLook/Tooltip");

CEGUI::WindowManager& WindowMgr = WindowManager::getSingleton();

RootWindow = WindowMgr.createWindow("WindowsLook/Static");
RootWindow->setProperty("FrameEnabled", "false");
CEGUISystem->setGUISheet(RootWindow);

CEGUI::Window* Dialog = WindowMgr.createWindow("WindowsLook/FrameWindow");
Dialog->setMinSize(UVector2(UDim(0, 400),UDim(0, 300)));
Dialog->setText("Window");
RootWindow->addChildWindow(Dialog);

That's all before your render loop.
Then, in your render loop add:
Code: [Select]

CEGUI::System::getSingleton().renderGUI();

Before your call to SFML's Window::Display().

To run that, you'll also need to have these files (from CEGUI-SDK/Samples/datafiles) in your app folder:
WindowsLook.scheme
WindowsLookWidgets.scheme
WindowsLook.tga
WindowsLook.imageset
DejaVuSans-10.font
DejaVuSans.ttf
WindowsLook.looknfeel

You'll also want to inject inputs into CEGUI.
Here's some code for that:
Code: [Select]

while (Window.GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::KeyPressed:
CEGUI::System::getSingleton().injectKeyDown(Event.Key.Code);
CEGUI::System::getSingleton().injectChar(Event.Text.Unicode);
break;
case sf::Event::KeyReleased:
CEGUI::System::getSingleton().injectKeyUp(Event.Key.Code);
break;
case sf::Event::MouseMoved:
CEGUI::System::getSingleton().injectMousePosition(Window.GetInput().GetMouseX(), Window.GetInput().GetMouseY());
break;
case sf::Event::MouseButtonPressed:
switch (Event.MouseButton.Button)
{
case sf::Mouse::Left:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
break;
case sf::Mouse::Middle:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
break;
case sf::Mouse::Right:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
break;
}
break;
case sf::Event::MouseButtonReleased:
switch (Event.MouseButton.Button)
{
case sf::Mouse::Left:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
break;
case sf::Mouse::Middle:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
break;
case sf::Mouse::Right:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
break;
}
break;
case sf::Event::MouseWheelMoved:
CEGUI::System::getSingleton().injectMouseWheelChange(Event.MouseWheel.Delta);
break;
}
}

Finally, I think that's all.
It takes a bit to get it all set up but it's worth it.
Sure beats writing your own GUI.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Mouse cursor enter/leave
« Reply #12 on: June 21, 2008, 05:41:37 am »
Why don't you put this tutorial on the wiki ? It would be useful to a many users ;)
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #13 on: June 21, 2008, 05:50:11 am »
Quote from: "Laurent"
Why don't you put this tutorial on the wiki ? It would be useful to a many users ;)

Oh yeah, that would be a good idea.
Will do.

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Mouse cursor enter/leave
« Reply #14 on: June 21, 2008, 03:40:18 pm »
Okay, here's the wiki tutorial:
http://sfml-dev.org/wiki/en/tutorials/CEGUI

If someone with the privileges can move the image+example off the external servers, I'd appreciate it.

 

anything