Logo Search packages:      
Sourcecode: blender version File versions

OSStatus GHOST_SystemCarbon::handleMouseEvent ( EventRef  event  )  [protected]

Handles a mouse event.

Parameters:
event A Mac event.
Returns:
Indication whether the event was handled.

Definition at line 689 of file GHOST_SystemCarbon.cpp.

References GHOST_WindowManager::getActiveWindow(), getMilliSeconds(), handleMouseDown(), GHOST_System::m_windowManager, and GHOST_System::pushEvent().

Referenced by sEventHandlerProc().

{
    OSStatus err = eventNotHandledErr;
      GHOST_IWindow* window = m_windowManager->getActiveWindow();
      UInt32 kind = ::GetEventKind(event);
                  
      switch (kind)
    {
            case kEventMouseDown:
            case kEventMouseUp:
                  // Handle Mac application responsibilities
                  if ((kind == kEventMouseDown) && handleMouseDown(event)) {
                        err = noErr;
                  }
                  else {
                        GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
                        EventMouseButton button;
                        
                        /* Window still gets mouse up after command-H */
                        if (m_windowManager->getActiveWindow()) {
                              ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
                              pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button)));
                              err = noErr;
                        }
                  }
            break;
                  
            case kEventMouseMoved:
        case kEventMouseDragged:
                  Point mousePos;
                  if (window) {
                        ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
                        pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
                        err = noErr;
                  }
            break;

            case kEventMouseWheelMoved:
                  {
                        OSStatus status;
                        //UInt32 modifiers;
                        EventMouseWheelAxis axis;
                        SInt32 delta;
                        //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
                        //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
                        status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis);
                        GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
                        if (axis == kEventMouseWheelAxisY)
                        {
                              status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta);
                              GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
                              /*
                               * Limit mouse wheel delta to plus and minus one.
                               */
                              delta = delta > 0 ? 1 : -1;
                              pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta));
                              err = noErr;
                        }
                  }
                  break;
            }
      
      return err;
}


Generated by  Doxygen 1.6.0   Back to index