How it works: If the element moused over is an edit box, the cursor will change to an I-beam. If it's moved away from one, it will change back to a normal arrow.
"device" is a pointer to your Irrlicht device. I'll let you handle the event receiver having access to this pointer yourself.
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_GUI_EVENT)
{
if (event.GUIEvent.EventType == EGET_ELEMENT_HOVERED)
{
// Set cursor to an I-Beam if hovering over an edit box
if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
{
device->getCursorControl()->setActiveIcon(ECI_IBEAM);
}
}
else if (event.GUIEvent.EventType == EGET_ELEMENT_LEFT)
{
// Set cursor to normal if left an edit box
if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
{
device->getCursorControl()->setActiveIcon(ECI_NORMAL);
}
}
}
}
}Other cursors in the Irrlicht engine if interested:
irr::gui::ECURSOR_ICON from ICursorControl.h
Code: Select all
//! Default icons for cursors
enum ECURSOR_ICON
{
// Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
ECI_NORMAL, // arrow
ECI_CROSS, // Crosshair
ECI_HAND, // Hand
ECI_HELP, // Arrow and question mark
ECI_IBEAM, // typical text-selection cursor
ECI_NO, // should not click icon
ECI_WAIT, // hourclass
ECI_SIZEALL, // arrow in all directions
ECI_SIZENESW, // resizes in direction north-east or south-west
ECI_SIZENWSE, // resizes in direction north-west or south-east
ECI_SIZENS, // resizes in direction north or south
ECI_SIZEWE, // resizes in direction west or east
ECI_UP, // up-arrow
// Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
// then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
// additionally.
ECI_COUNT // maximal of defined cursors. Note that higher values can be created at runtime
};