text edit (not finished)

This commit is contained in:
Eduardo Bart
2011-04-11 01:08:56 -03:00
parent bab83308cf
commit da2993d1f9
29 changed files with 302 additions and 203 deletions

View File

@@ -141,10 +141,13 @@ void Engine::onResize(const Size& size)
void Engine::onInputEvent(const InputEvent& event)
{
// inputs goest to gui first
if(!UIContainer::getRootContainer()->onInputEvent(event)) {
// if gui didnt capture the input then goes to the state
if(m_currentState)
m_currentState->onInputEvent(event);
}
bool eventCaptured = false;
// events goes to the state first
if(m_currentState)
eventCaptured = m_currentState->onInputEvent(event);
// if the state didn't capture the input then goes to the gui
if(!eventCaptured)
UIContainer::getRootContainer()->onInputEvent(event);
}

View File

@@ -40,7 +40,7 @@ public:
virtual void onLeave() = 0;
virtual void onClose() = 0;
virtual void onInputEvent(const InputEvent& event) = 0;
virtual bool onInputEvent(const InputEvent& event) = 0;
virtual void onResize(const Size& size) = 0;
virtual void render() = 0;

View File

@@ -176,22 +176,31 @@ enum EKeyCode {
};
enum EEvent {
EV_KEY_DOWN = 0,
EV_KEY_UP,
EV_TEXT_ENTER,
EV_MOUSE_LDOWN,
EV_MOUSE_LUP,
EV_MOUSE_MDOWN,
EV_MOUSE_MUP,
EV_MOUSE_RDOWN,
EV_MOUSE_RUP,
EV_MOUSE_WHEEL_UP,
EV_MOUSE_WHEEL_DOWN,
EV_MOUSE_MOVE
EV_MOUSE = 1,
EV_KEYBOARD = 2,
EV_DOWN = 4,
EV_UP = 8,
EV_MOUSE_MOVE = 32,
EV_MOUSE_WHEEL = 64,
EV_MOUSE_LEFT = 128,
EV_MOUSE_RIGHT = 256,
EV_MOUSE_MIDDLE = 512,
EV_TEXT_ENTER = EV_KEYBOARD | 1024,
EV_KEY_DOWN = EV_KEYBOARD | EV_DOWN,
EV_KEY_UP = EV_KEYBOARD | EV_UP,
EV_MOUSE_LDOWN = EV_MOUSE | EV_DOWN | EV_MOUSE_LEFT,
EV_MOUSE_LUP = EV_MOUSE | EV_KEY_UP | EV_MOUSE_LEFT,
EV_MOUSE_MDOWN = EV_MOUSE | EV_DOWN | EV_MOUSE_MIDDLE,
EV_MOUSE_MUP = EV_MOUSE | EV_KEY_UP | EV_MOUSE_MIDDLE,
EV_MOUSE_RDOWN = EV_MOUSE | EV_DOWN | EV_MOUSE_RIGHT,
EV_MOUSE_RUP = EV_MOUSE | EV_KEY_UP | EV_MOUSE_RIGHT,
EV_MOUSE_WHEEL_UP = EV_MOUSE | EV_MOUSE_WHEEL | EV_UP,
EV_MOUSE_WHEEL_DOWN = EV_MOUSE | EV_MOUSE_WHEEL | EV_DOWN
};
struct InputEvent {
EEvent type;
int type;
Point mousePos;
char keychar;
uchar keycode;