/*! SLCamera::onKeyPress applies the keyboard view navigation to the view matrix. The key code constants are defined in SL.h */ SLbool SLCamera::onKeyPress(const SLKey key, const SLKey mod) { switch ((SLchar)key) { case 'W': _maxSpeed.z = _speedLimit; return true; case 'S': _maxSpeed.z =-_speedLimit; return true; case 'A': _maxSpeed.x = _speedLimit; return true; case 'D': _maxSpeed.x =-_speedLimit; return true; case 'Q': _maxSpeed.y = _speedLimit; return true; case 'E': _maxSpeed.y =-_speedLimit; return true; case (SLchar)KeyDown: return onMouseWheel( 1, mod); case (SLchar)KeyUp: return onMouseWheel(-1, mod); default: return false; } }
void onMouse(int button, int state, int x, int y) { if (button == 3) onMouseWheel(button, 1, x, y); if (button == 4) onMouseWheel(button, -1, x, y); if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { isCameraRotate = true; prevxPos = x; prevyPos = y; } else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) { isCameraRotate = false; } }
bool WebPluginScrollbarImpl::handleInputEvent(const WebInputEvent& event) { switch (event.type) { case WebInputEvent::MouseDown: return onMouseDown(event); case WebInputEvent::MouseUp: return onMouseUp(event); case WebInputEvent::MouseMove: return onMouseMove(event); case WebInputEvent::MouseLeave: return onMouseLeave(event); case WebInputEvent::MouseWheel: return onMouseWheel(event); case WebInputEvent::KeyDown: return onKeyDown(event); case WebInputEvent::Undefined: case WebInputEvent::MouseEnter: case WebInputEvent::RawKeyDown: case WebInputEvent::KeyUp: case WebInputEvent::Char: case WebInputEvent::TouchStart: case WebInputEvent::TouchMove: case WebInputEvent::TouchEnd: case WebInputEvent::TouchCancel: default: break; } return false; }
void TextureControl::notifyMouseWheel(MyGUI::Widget* _sender, int _rel) { mMouseLeftPressed = false; if (!getSelectorsCapture()) { saveMouseRelative(); onMouseWheel(_rel); loadMouseRelative(); } }
int _tmain(int argc, _TCHAR* argv[]) { if (!init()) { printf("Failed to initialize!\n"); return 0; } bool quit = false; while (!quit) { SDL_Event e; while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { quit = true; } else if (e.type == SDL_MOUSEBUTTONDOWN) { onMouseDown(e.button); } else if (e.type == SDL_MOUSEBUTTONUP) { onMouseUp(e.button); } else if (e.type == SDL_MOUSEWHEEL) { onMouseWheel(e.wheel); } else if (e.type == SDL_KEYDOWN) { OnKeyDown(e.key); } else if (e.type == SDL_WINDOWEVENT) { onWindowEvent(e.window); } } // Render render(); // Update screen SDL_GL_SwapWindow(gWindow); } // Free resources and close SDL close(); return 0; }
void geGUIBase::MouseWheel(int zDelta, int x, int y, int flag) { if(m_uGUIID==GEGUI_LAYOUT && getActiveWindowPtrOnlyForLayout()) //layout hack { getActiveWindowPtrOnlyForLayout()->MouseWheel(zDelta, x-getPos().x, y-getPos().y-getTopMarginOffsetHeight(), flag); } else { for(std::vector<geGUIBase*>::iterator it = m_vControls.begin(); it != m_vControls.end(); ++it) { geGUIBase* obj = *it; obj->MouseWheel(zDelta, x-getPos().x, y-getPos().y-getTopMarginOffsetHeight(), flag); } } onMouseWheel(zDelta, x-getPos().x, y-getPos().y-getTopMarginOffsetHeight(), flag); }
LRESULT WebPopupMenuProxyWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lResult = 0; bool handled = true; switch (message) { case WM_MOUSEACTIVATE: lResult = onMouseActivate(hWnd, message, wParam, lParam, handled); break; case WM_SIZE: lResult = onSize(hWnd, message, wParam, lParam, handled); break; case WM_KEYDOWN: lResult = onKeyDown(hWnd, message, wParam, lParam, handled); break; case WM_CHAR: lResult = onChar(hWnd, message, wParam, lParam, handled); break; case WM_MOUSEMOVE: lResult = onMouseMove(hWnd, message, wParam, lParam, handled); break; case WM_LBUTTONDOWN: lResult = onLButtonDown(hWnd, message, wParam, lParam, handled); break; case WM_LBUTTONUP: lResult = onLButtonUp(hWnd, message, wParam, lParam, handled); break; case WM_MOUSEWHEEL: lResult = onMouseWheel(hWnd, message, wParam, lParam, handled); break; case WM_PAINT: lResult = onPaint(hWnd, message, wParam, lParam, handled); break; case WM_PRINTCLIENT: lResult = onPrintClient(hWnd, message, wParam, lParam, handled); break; default: handled = false; break; } if (!handled) lResult = ::DefWindowProc(hWnd, message, wParam, lParam); return lResult; }
void Engine::proccessEvent(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: stop(); break; case WM_MOUSEMOVE: onMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam); break; case WM_MOUSELEAVE: onMouseLeave(); break; case WM_MOUSEWHEEL: onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam)); break; case WM_KEYDOWN: onKeyDown(wParam); break; } }
void Scene::processEvents() { SDL_Event event; // Events of SDL while ( SDL_PollEvent(&event) ) { if(PGE_Window::processEvents(event)!=0) continue; switch(event.type) { case SDL_QUIT: { doExit = true; running = false; _doShutDown = true; break; }// End work of program break; case SDL_KEYDOWN: // If pressed key onKeyboardPressedSDL(event.key.keysym.sym, event.key.keysym.mod); onKeyboardPressed(event.key.keysym.scancode); break; case SDL_KEYUP: // If released key onKeyboardReleasedSDL(event.key.keysym.sym, event.key.keysym.mod); onKeyboardReleased(event.key.keysym.scancode); break; case SDL_MOUSEBUTTONDOWN: onMousePressed(event.button); break; case SDL_MOUSEBUTTONUP: onMouseReleased(event.button); break; case SDL_MOUSEWHEEL: onMouseWheel(event.wheel); break; case SDL_MOUSEMOTION: onMouseMoved(event.motion); break; } } }
void Camera::onEvent(const sf::Event& event) { if (event.type == sf::Event::MouseButtonPressed) { lastX = event.mouseButton.x; lastY = event.mouseButton.y; // std::cout << lastX << ", " << lastY << std::endl; toggled = true; } if (event.type == sf::Event::MouseButtonReleased) { lastX = event.mouseButton.x; lastY = event.mouseButton.y; toggled = false; } if (event.type == sf::Event::MouseMoved) { float mx = event.mouseMove.x; float my = event.mouseMove.y; if (toggled) { onMouseMove(lastX - mx, lastY - my); } lastX = mx; lastY = my; } if (event.type == sf::Event::MouseWheelScrolled) { onMouseWheel(event.mouseWheelScroll.delta); } }
bool UIWidget::propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction) { // do a backup of children list, because it may change while looping it UIWidgetList children; for(const UIWidgetPtr& child : m_children) { // events on hidden or disabled widgets are discarded if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible()) continue; // mouse wheel events only go to children that contains the mouse position if(child->containsPoint(mousePos) && child == getChildByPos(mousePos)) children.push_back(child); } for(const UIWidgetPtr& child : children) { if(child->propagateOnMouseWheel(mousePos, direction)) return true; } if(!isPhantom()) return onMouseWheel(mousePos, direction); else return false; }
INT_PTR CALLBACK NavDialog::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: break; case WM_PAINT: onPaint(); break; case WM_LBUTTONDOWN: ::SetCapture(_hSelf); setPos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_LBUTTONUP: ::ReleaseCapture(); break; case WM_MOUSEMOVE: if (::GetCapture() == _hSelf) setPos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); else if (!m_mouseOver) m_mouseOver = true; break; case WM_MOUSELEAVE: if (m_mouseOver) m_mouseOver = false; break; case WM_MOUSEWHEEL: if (m_mouseOver) onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam) / 120); break; case WM_VSCROLL: { switch (LOWORD(wParam)) { case SB_THUMBPOSITION: case SB_THUMBTRACK: { const int currentScroll = HIWORD(wParam); ::SetFocus(_hSelf); ::SetScrollPos(m_hScroll, SB_CTL, currentScroll, TRUE); ::InvalidateRect(_hSelf, NULL, FALSE); } break; case SB_PAGEDOWN: adjustScroll(m_navHeight); break; case SB_PAGEUP: adjustScroll(-m_navHeight); break; case SB_LINEDOWN: adjustScroll(1); break; case SB_LINEUP: adjustScroll(-1); break; } } break; case WM_SIZE: case WM_MOVE: if (isVisible()) SetScalingFactor(); break; case WM_NOTIFY: { LPNMHDR pnmh = (LPNMHDR)lParam; if (pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_CLOSE) { ViewNavigationBar(); } else if ((pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_FLOAT) || (pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_DOCK)) { SetScalingFactor(); ::SetFocus(m_syncView->m_hView); } } break; default: return DockingDlgInterface::run_dlgProc(Message, wParam, lParam); } return FALSE; }
void COSXScreen::handleSystemEvent(const CEvent& event, void*) { EventRef* carbonEvent = reinterpret_cast<EventRef*>(event.getData()); assert(carbonEvent != NULL); UInt32 eventClass = GetEventClass(*carbonEvent); switch (eventClass) { case kEventClassMouse: switch (GetEventKind(*carbonEvent)) { case kEventMouseDown: { UInt16 myButton; GetEventParameter(*carbonEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(myButton), NULL, &myButton); onMouseButton(true, myButton); break; } case kEventMouseUp: { UInt16 myButton; GetEventParameter(*carbonEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(myButton), NULL, &myButton); onMouseButton(false, myButton); break; } case kEventMouseDragged: case kEventMouseMoved: { HIPoint point; GetEventParameter(*carbonEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(point), NULL, &point); onMouseMove((SInt32)point.x, (SInt32)point.y); break; } case kEventMouseWheelMoved: { EventMouseWheelAxis axis; SInt32 delta; GetEventParameter(*carbonEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis); if (axis == kEventMouseWheelAxisX || axis == kEventMouseWheelAxisY) { GetEventParameter(*carbonEvent, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); if (axis == kEventMouseWheelAxisX) { onMouseWheel(-mapScrollWheelToSynergy((SInt32)delta), 0); } else { onMouseWheel(0, mapScrollWheelToSynergy((SInt32)delta)); } } break; } case kSynergyEventMouseScroll: { OSStatus r; long xScroll; long yScroll; // get scroll amount r = GetEventParameter(*carbonEvent, kSynergyMouseScrollAxisX, typeLongInteger, NULL, sizeof(xScroll), NULL, &xScroll); if (r != noErr) { xScroll = 0; } r = GetEventParameter(*carbonEvent, kSynergyMouseScrollAxisY, typeLongInteger, NULL, sizeof(yScroll), NULL, &yScroll); if (r != noErr) { yScroll = 0; } if (xScroll != 0 || yScroll != 0) { onMouseWheel(-mapScrollWheelToSynergy(xScroll), mapScrollWheelToSynergy(yScroll)); } } } break; case kEventClassKeyboard: switch (GetEventKind(*carbonEvent)) { case kEventRawKeyUp: case kEventRawKeyDown: case kEventRawKeyRepeat: case kEventRawKeyModifiersChanged: onKey(*carbonEvent); break; case kEventHotKeyPressed: case kEventHotKeyReleased: onHotKey(*carbonEvent); break; } break; case kEventClassWindow: SendEventToWindow(*carbonEvent, m_userInputWindow); switch (GetEventKind(*carbonEvent)) { case kEventWindowActivated: LOG((CLOG_DEBUG1 "window activated")); break; case kEventWindowDeactivated: LOG((CLOG_DEBUG1 "window deactivated")); break; case kEventWindowFocusAcquired: LOG((CLOG_DEBUG1 "focus acquired")); break; case kEventWindowFocusRelinquish: LOG((CLOG_DEBUG1 "focus released")); break; } break; default: SendEventToEventTarget(*carbonEvent, GetEventDispatcherTarget()); break; } }
void COSXScreen::handleSystemEvent(const CEvent& event, void*) { EventRef* carbonEvent = reinterpret_cast<EventRef*>(event.getData()); assert(carbonEvent != NULL); UInt32 eventClass = GetEventClass(*carbonEvent); switch (eventClass) { case kEventClassMouse: switch (GetEventKind(*carbonEvent)) { case kSynergyEventMouseScroll: { OSStatus r; long xScroll; long yScroll; // get scroll amount r = GetEventParameter(*carbonEvent, kSynergyMouseScrollAxisX, typeLongInteger, NULL, sizeof(xScroll), NULL, &xScroll); if (r != noErr) { xScroll = 0; } r = GetEventParameter(*carbonEvent, kSynergyMouseScrollAxisY, typeLongInteger, NULL, sizeof(yScroll), NULL, &yScroll); if (r != noErr) { yScroll = 0; } if (xScroll != 0 || yScroll != 0) { onMouseWheel(-mapScrollWheelToSynergy(xScroll), mapScrollWheelToSynergy(yScroll)); } } } break; case kEventClassKeyboard: switch (GetEventKind(*carbonEvent)) { case kEventHotKeyPressed: case kEventHotKeyReleased: onHotKey(*carbonEvent); break; } break; case kEventClassWindow: SendEventToWindow(*carbonEvent, m_userInputWindow); switch (GetEventKind(*carbonEvent)) { case kEventWindowActivated: LOG((CLOG_DEBUG1 "window activated")); break; case kEventWindowDeactivated: LOG((CLOG_DEBUG1 "window deactivated")); break; case kEventWindowFocusAcquired: LOG((CLOG_DEBUG1 "focus acquired")); break; case kEventWindowFocusRelinquish: LOG((CLOG_DEBUG1 "focus released")); break; } break; default: SendEventToEventTarget(*carbonEvent, GetEventDispatcherTarget()); break; } }
void PaintBox::MouseWheel(Point p, int zdelta, dword keyflags) { onMouseWheel(p,zdelta, keyflags); }
void Window::notifyMouseWheel(MyGUI::Widget* _sender, int _rel) { onMouseWheel(_rel); eventMouseWheel(_sender, _rel); }
void WidgetInput::_riseMouseWheel(int _rel) { onMouseWheel(_rel); eventMouseWheel(static_cast<Widget*>(this), _rel); }
void geSecondryView::mouseWheel(int zDelta, int x, int y, int flag) { onMouseWheel(zDelta, x, y, flag); }
void TreeControlItem::notifyMouseWheel(Widget* pSender, int nValue) { if (pSender && pSender->getParent() == this) onMouseWheel(nValue); }
void OccView::wheelEvent( QWheelEvent * theEvent ) { onMouseWheel(theEvent->buttons(), theEvent->delta(), theEvent->pos()); }
/// event handlers void Module::onEvent(const SDL_Event& inEvent) { switch (inEvent.type) { case SDL_ACTIVEEVENT: { switch (inEvent.active.state) { case SDL_APPMOUSEFOCUS: { if (inEvent.active.gain) onMouseFocus(); else onMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if (inEvent.active.gain) onInputFocus(); else onInputBlur(); break; } case SDL_APPACTIVE: { if (inEvent.active.gain) onRestore(); else onMinimize(); break; } } break; } case SDL_KEYDOWN: { onKeyDown(inEvent.key.keysym.sym, inEvent.key.keysym.mod, inEvent.key.keysym.unicode); break; } case SDL_KEYUP: { onKeyUp(inEvent.key.keysym.sym, inEvent.key.keysym.mod, inEvent.key.keysym.unicode); break; } case SDL_MOUSEMOTION: { onMouseMove(inEvent.motion.x, inEvent.motion.y, inEvent.motion.xrel, inEvent.motion.yrel, inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_LEFT), inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT), inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE)); break; } case SDL_MOUSEBUTTONDOWN: { switch (inEvent.button.button) { case SDL_BUTTON_LEFT: { onLButtonDown(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonDown(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonDown(inEvent.button.x, inEvent.button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch (inEvent.button.button) { case SDL_BUTTON_LEFT: { onLButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_WHEELUP: { onMouseWheel(true, false); break; } case SDL_BUTTON_WHEELDOWN: { onMouseWheel(false, true); break; } } break; } case SDL_JOYAXISMOTION: { onJoyAxis(inEvent.jaxis.which, inEvent.jaxis.axis, inEvent.jaxis.value); break; } case SDL_JOYBALLMOTION: { onJoyBall(inEvent.jball.which, inEvent.jball.ball, inEvent.jball.xrel, inEvent.jball.yrel); break; } case SDL_JOYHATMOTION: { onJoyHat(inEvent.jhat.which, inEvent.jhat.hat, inEvent.jhat.value); break; } case SDL_JOYBUTTONDOWN: { onJoyButtonDown(inEvent.jbutton.which, inEvent.jbutton.button); break; } case SDL_JOYBUTTONUP: { onJoyButtonUp(inEvent.jbutton.which, inEvent.jbutton.button); break; } case SDL_QUIT: { onExit(); break; } case SDL_SYSWMEVENT: { break; } case SDL_VIDEORESIZE: { onResize(inEvent.resize.w, inEvent.resize.h); break; } case SDL_VIDEOEXPOSE: { onExpose(); break; } default: { onUser(inEvent.user.type, inEvent.user.code, inEvent.user.data1, inEvent.user.data2); break; } } }