You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
749 B

#include <global.h>
13 years ago
#include <core/dispatcher.h>
#include <ui/uibutton.h>
13 years ago
#include "uicontainer.h"
13 years ago
void UIButton::onInputEvent(const InputEvent& event)
{
if(event.type == EV_MOUSE_LDOWN && getRect().contains(event.mousePos)) {
m_state = ButtonDown;
} else if(event.type == EV_MOUSE_LUP && m_state == ButtonDown) {
m_state = ButtonUp;
if(getRect().contains(event.mousePos)) {
LuaObjectPtr me = asLuaObject();
g_dispatcher.addTask([me] {
me->callField("onClick");
});
}
13 years ago
} else if(event.type == EV_MOUSE_MOVE && m_state != ButtonDown) {
13 years ago
if(isMouseOver())
13 years ago
m_state = ButtonMouseOver;
else
m_state = ButtonUp;
}
}