UI Objects

Learn how to setup UI Objects Callbacks

Button Object Callbacks

Button objects offer three callbacks

  • OnMouseEnter : called when the mouse comes hover the button
  • OnMouseLeave : called when the mouse leaves the button surface
  • OnMouseClick : called when you click on the button
Those three callbacks are setup using lambda functions. The signature used is : std::function<void()>, which means a function with no parameter returning void.
//Retrieve your button as generic Object
nero::Object::Ptr object = getObjectManager()->findScreenUIObject("screen_name", "button_name");
//Convert back to Button Object
nero::ButtonObject::Ptr my_button = nero::ButtonObject::Cast(object);
//Set up your callbacks using lambda functions my_button->setOnMouseEnter([this]() { //do something, play sound, etc. }) my_button->setOnMouseLeave([this]() { //do something, play sound, etc. }) my_button->setOnMouseClick([this]() { //do something, play sound, etc. })