One of the most useful features of the Ruminate GUI is the input system that allows you to replace the default XNA polling system with event driven input. The code to do this is very simple.

First initialize a instance of the Gui class. If you wan't to use the library for input only and have no need for the graphical GUI widgets you can pass in null for both the skin and font.

var _gui = new Gui(game, null, null);

After the GUI has been Initialized simply subscribe to any of the below events.

_gui.CharEntered += CharEntered;
_gui.KeyDown += KeyDown;
_gui.KeyUp += KeyUp;
_gui.MouseDoubleClick += MouseDoubleClick;
_gui.MouseDown += MouseDown;
_gui.MouseHover += MouseHover;
_gui.MouseUp += MouseUp;
_gui.MouseWheel += MouseWheel;

The GUI class has a property called HasMouse. This property is useful for blocking input when the user has their cursor over a widget. This allows you not effect your game state while the user is interacting with the GUI.

For a thorough demonstration of the Event driven input people see InputTest.cs in the example project. To down load the example project checkout or download the latest commit under the source code tab.

Last edited Sep 7, 2012 at 10:13 AM by ClassicThunder, version 2

Comments

No comments yet.