(0.0.0) Mouse Event Callback - JujuAdams/Bento GitHub Wiki

///Create Event
//Define our base container
box = bento_box(20, 20, room_width-20, room_height-20)
with(box)
{
    //Start with a yellow colour
    style.fill.color = c_yellow;
    
    //Define a generic mouse event callback function
    //This callback is called in the scope of the element and takes one argument
    callbacks.mouse_event = function(_event)
    {
        switch(_event)
        {
            case "leave":    style.fill.color = c_yellow; break;
            case "enter":    style.fill.color = c_orange; break;
            case "pressed":  style.fill.color = c_red;    break;
            case "released": style.fill.color = c_orange; break;
        }
    }
}


///Step Event
//Perform mouse detection every step
bento_tick_mouse(box, mouse_x, mouse_y, mouse_check_button(mb_left));

A list of all mouse callbacks can be found on the Callbacks page.