Exemple #1
0
void Record::mousePressEvent(QMouseEvent *event) {
    if(event->button() == Qt::LeftButton) {
        oldStartTime = m_StartTime;
        onMousePress(m_Id, m_StartTime, m_EndTime, m_Name);
        this->raise();
        dragMouseOffsetX = event->pos().x();

        Palette->setColor(QPalette::Background, Qt::blue);
        this->setPalette(*Palette);
    }
    event->ignore();
}
bool DesignerEventHandler::eventFilter(QObject* o, QEvent* e)
{
  switch (e->type()){
//    case QEvent::ContextMenu:
//      qDebug () << "context menu event !!!";
//    break;
    case QEvent::MouseButtonPress:
      //context_widget = dynamic_cast<VtlWidget*>(o);
      onMousePress((QMouseEvent*)e);
    break;
    case QEvent::MouseMove:
      onMouseMove((QMouseEvent*)e);
    break;
    case QEvent::MouseButtonRelease:	
      onMouseRelease((QMouseEvent*)e);
      //context_widget = 0;
    break;
    case QEvent::MouseButtonDblClick:
    	showWidgetProperties();
        break;
    case QEvent::ContextMenu:
        //qDebug () << o->className();
        qDebug () << "context menu event !!!";
        onContextMenu((QContextMenuEvent*)e);
    break;
    case QEvent::KeyPress:
      onKeyPress((QKeyEvent*)e);
    break;
//    case QEvent::Paint:
//      onPaintEvent ( static_cast<QPaintEvent*>(e) );
//    break;
    case OutsideEvent::Outside:{
      VtlWidget * w = ((OutsideEvent *)e)->widget();
      if (selections[w]){
        selections[w]->updateSelectionPos();
      }
    }
    return true;
    case AddToSelEvent::AddToSel:
      if (static_cast<AddToSelEvent*>(e)->clearSel())
        clearSelection( );
      addWidgetToSelection(static_cast<AddToSelEvent*>(e)->widget());
    return true;
    default:
    break;
  }
  return QObject::eventFilter(o, e);
}
void ofxDatGuiComponent::update(bool acceptEvents)
{
// if window does not have focus x & y will both be zero //
    if (acceptEvents && mEnabled && mVisible){
        bool mp = ofGetMousePressed();
        ofPoint mouse = ofPoint(ofGetMouseX() - mParentPosition.x, ofGetMouseY() - mParentPosition.y);
        if (hitTest(mouse)){
            if (!mMouseOver){
                onMouseEnter(mouse);
            }
            if (!mMouseDown && mp){
                onMousePress(mouse);
                if (!mFocused) onFocus();
            }
        }   else{
    // the mouse is not over the component //
            if (mMouseOver){
                onMouseLeave(mouse);
            }
            if (!mMouseDown && mp && mFocused){
                onFocusLost();
            }
        }
        if (mMouseDown) {
            if (mp){
                onMouseDrag(mouse);
            }   else{
                onMouseRelease(mouse);
            }
        }
    }
// don't update children unless they're visible //
    if (this->getIsExpanded()) {
        for(int i=0; i<children.size(); i++) {
            children[i]->update(acceptEvents);
            if (children[i]->getFocused()){
                if (acceptEvents == false ) children[i]->setFocused(false);
                acceptEvents = false;
            }
        }
    }
}
Exemple #4
0
bool UIWidget::propagateOnMousePress(const Point& mousePos, Fw::MouseButton button)
{
    // do a backup of children list, because it may change while looping it
    UIWidgetPtr clickedChild;
    for(const UIWidgetPtr& child : m_children) {
        // events on hidden or disabled widgets are discarded
        if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible())
            continue;

        // mouse press events only go to children that contains the mouse position
        if(child->containsPoint(mousePos) && child == getChildByPos(mousePos)) {
            clickedChild = child;
            break;
        }
    }

    if(clickedChild) {
        // focusable child gains focus when clicked
        if(clickedChild->isFocusable())
            focusChild(clickedChild, Fw::MouseFocusReason);

        // stop propagating if the child accept the event
        if(clickedChild->propagateOnMousePress(mousePos, button))
            return true;
    }

    // only non phatom widgets receives mouse press events
    if(!isPhantom()) {
        bool ret = onMousePress(mousePos, button);
        if(button == Fw::MouseLeftButton && !isPressed())
            setPressed(true);
        return ret;
    }

    return false;
}
Exemple #5
0
void Sprite::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    emit onMousePress(event->pos().x(),event->pos().y(),event->buttons());
}
Exemple #6
0
void Platform::loop()
{
    SDL_Event event;
    while(!m_done)
    {
    	Scheduler::Poll();

        while(!m_done && SDL_PollEvent(&event))
        {
            switch(event.type)
            {
#if defined(WIN32)
                // mouse
                case SDL_MOUSEMOTION:
                    onMouseMove(1, {event.motion.x * g_graphic->getDrawDimension().w / g_graphic->getWindowWidth(),
                            		event.motion.y * g_graphic->getDrawDimension().h / g_graphic->getWindowHeight() });
                    break;
                case SDL_MOUSEBUTTONDOWN:
                case SDL_MOUSEBUTTONUP:
                {
                	Point point;
                	point.x = event.motion.x * g_graphic->getDrawDimension().w / g_graphic->getWindowWidth();
                	point.y = event.motion.y * g_graphic->getDrawDimension().h / g_graphic->getWindowHeight();
                    onMousePress(event.button.button, point, event.button.state);
                    break;
                }

                // finger
#elif defined(ANDROID)
                case SDL_FINGERMOTION:
                {
                    Point pos = {(int32_t)(event.tfinger.x * g_graphic->getDrawDimension().w),
                                 (int32_t)(event.tfinger.y * g_graphic->getDrawDimension().h)};
                    onMouseMove(1 + event.tfinger.fingerId, pos);
                    break;
                }
                case SDL_FINGERDOWN:
                case SDL_FINGERUP:
                {
                    Point pos = {(int32_t)(event.tfinger.x * g_graphic->getDrawDimension().w),
                                 (int32_t)(event.tfinger.y * g_graphic->getDrawDimension().h)};
                    onMousePress(1 + event.tfinger.fingerId, pos, event.type == SDL_FINGERDOWN);
                    break;
                }
#endif
                case SDL_KEYDOWN:
                	onKeyPress((uint16_t)event.key.keysym.sym, true);
                    break;
                case SDL_KEYUP:
                	onKeyPress((uint16_t)event.key.keysym.sym, false);
                    break;
                case SDL_DROPFILE:
                {
                	std::string path = g_fileManager.resolvePath(event.drop.file);
                	onDragFile(path);

                	SDL_free(event.drop.file);
                    break;
                }
                case SDL_WINDOWEVENT:
                {
                    switch(event.window.event)
                    {
                    	case SDL_WINDOWEVENT_FOCUS_GAINED:
                    		m_hasWindowFocus = true;
                            break;
                        case SDL_WINDOWEVENT_FOCUS_LOST:
                    		m_hasWindowFocus = false;
                            break;

                        case SDL_WINDOWEVENT_RESIZED:
                        case SDL_WINDOWEVENT_SIZE_CHANGED:
                        {
                            g_graphic->init(event.window.data1, event.window.data2);
                            g_painter.resetDrawArea();
                            g_graphic->render();

                            g_lua["onWindowResize"].call(event.window.data1, event.window.data2);
                            break;
                        }
                    }

                    break;
                }
                case SDL_APP_LOWMEMORY:
                	LOGI("Low Memory");
                case SDL_APP_TERMINATING:
                	LOGI("Terminating");
                case SDL_QUIT:
                	LOGI("Quit");
                	m_done = true;
                	break;
            }
        }

        if(!m_done)
        	g_graphic->render();
    }
}