示例#1
0
文件: EHLevel.cpp 项目: jdmack/tlb
bool EHLevel::handleEvent(Event * event)
{
    bool ret = false;

    switch(event->type()) {
        case EVENT_MOUSE_CLICK:
        {
            EMouse * mouseEvent = static_cast<EMouse *>(event);
            //Logger::write(Logger::ss << "Mouse Click " << mouseEvent->position().toString());
            if(mouseEvent->button() == MOUSE_BUTTON_LEFT) {
                mouseLeftClick(mouseEvent->position());
            }
            else if(mouseEvent->button() == MOUSE_BUTTON_RIGHT) {
                mouseRightClick(mouseEvent->position());
            }

            ret = true;
            break;
        }
        case EVENT_MOUSE_MOTION:
        {
            EMouse * mouseEvent = static_cast<EMouse *>(event);
            mouseMotion(mouseEvent->position());

            ret = true;
            break;
        }
        case EVENT_GAME_QUIT:
        {
            Game::instance()->setQuit(true);

            ret = true;
            break;
        }

        case EVENT_KEY_PRESS:
        {
            EKeyPress * keyEvent = static_cast<EKeyPress *>(event);
            keyPress(keyEvent->keyType());

            ret = true;
            break;
        }
    }
    return ret;
}
示例#2
0
// virtual
void ClickableLabel::mouseReleaseEvent(QMouseEvent * event)
{
	if ((event->pos() - mouseStartPoint).manhattanLength() < QApplication::startDragDistance()) {
		switch (event->button()) {
			case Qt::LeftButton:
				emit mouseLeftClick(event);
				break;
			case Qt::RightButton:
				emit mouseRightClick(event);
				break;
			case Qt::MidButton:
				emit mouseMiddleClick(event);
				break;
			default:
				break;
		}
	}
}