bool iWidget::ProcessMessage(eGuiMessage a_Message, cGuiMessageData &a_Data) { if (IsEnabled()==false) return false; a_Data.m_Message = a_Message; bool bRet = false; bRet = OnMessage(a_Message, a_Data); if (bRet==false) { switch(a_Message) { case eGuiMessage_MouseMove: bRet = OnMouseMove(a_Data);break; case eGuiMessage_MouseDown: bRet = OnMouseDown(a_Data);break; case eGuiMessage_MouseUp: bRet = OnMouseUp(a_Data);break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(a_Data);break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(a_Data);break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(a_Data);break; case eGuiMessage_GotFocus: bRet = OnGotFocus(a_Data);break; case eGuiMessage_LostFocus: bRet = OnLostFocus(a_Data);break; case eGuiMessage_KeyPress: bRet = OnKeyPress(a_Data);break; } } if (ProcessCallbacks(a_Message, a_Data)) bRet = true; return bRet; }
void SDLApp::PumpEvents() { SDL_PumpEvents(); SDL_Event event; while ( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_QUIT: run_ = false; break; case SDL_MOUSEBUTTONUP: OnMouseUp(event.button.x, event.button.y); break; case SDL_MOUSEBUTTONDOWN: OnMouseDown(event.button.x, event.button.y); break; case SDL_MOUSEMOTION: OnMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); break; default: break; } } }
bool iWidget::ProcessMessage(eGuiMessage aMessage, cGuiMessageData &aData) { if(IsEnabled()==false) return false; aData.mMessage = aMessage; bool bRet = false; bRet = OnMessage(aMessage,aData); //This can override any message. ///////////////////////////////////////// //Call the correct virtual function if(bRet==false) { switch(aMessage) { case eGuiMessage_MouseMove: bRet = OnMouseMove(aData); break; case eGuiMessage_MouseDown: bRet = OnMouseDown(aData); break; case eGuiMessage_MouseUp: bRet = OnMouseUp(aData); break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(aData); break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(aData); break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(aData); break; case eGuiMessage_KeyPress: bRet = OnKeyPress(aData); break; case eGuiMessage_GotFocus: bRet = OnGotFocus(aData); break; case eGuiMessage_LostFocus: bRet = OnLostFocus(aData); break; } } ///////////////////////////////////////// //Process user callbacks for the event. if(ProcessCallbacks(aMessage,aData)) bRet = true; return bRet; }
bool Window::OnMouseDouble(PixelPoint p) { /* fall back to OnMouseDown() if the class didn't override OnMouseDouble() */ return OnMouseDown(p); }
void wxRibbonGallery::OnMouseDClick(wxMouseEvent& evt) { // The 2nd click of a double-click should be handled as a click in the // same way as the 1st click of the double-click. This is useful for // scrolling through the gallery. OnMouseDown(evt); OnMouseUp(evt); }
bool CButton::OnMouseDown(LPARAM lParam) { //得到的鼠标坐标系:原点位于左上角 // Y轴向下 int MouseX = LOWORD(lParam); int MouseY = HIWORD(lParam); return OnMouseDown(MouseX, MouseY); }
bool TopWindow::OnEvent(const Event &event) { switch (event.type) { Window *w; case Event::NOP: case Event::QUIT: case Event::TIMER: case Event::USER: case Event::CALLBACK: break; case Event::CLOSE: OnClose(); break; case Event::KEY_DOWN: w = GetFocusedWindow(); if (w == nullptr) w = this; return w->OnKeyDown(event.param); case Event::KEY_UP: w = GetFocusedWindow(); if (w == nullptr) w = this; return w->OnKeyUp(event.param); case Event::MOUSE_MOTION: #ifdef DRAW_MOUSE_CURSOR /* redraw to update the mouse cursor position */ Invalidate(); #endif // XXX keys return OnMouseMove(event.point.x, event.point.y, 0); case Event::MOUSE_DOWN: return double_click.Check(event.point) ? OnMouseDouble(event.point.x, event.point.y) : OnMouseDown(event.point.x, event.point.y); case Event::MOUSE_UP: double_click.Moved(event.point); return OnMouseUp(event.point.x, event.point.y); case Event::MOUSE_WHEEL: return OnMouseWheel(event.point.x, event.point.y, (int)event.param); } return false; }
bool Window::OnMouseDouble(PixelScalar x, PixelScalar y) { #ifndef USE_GDI if (!double_clicks) return OnMouseDown(x, y); #endif return false; }
void TAbstractEditor::OnMouseDown(TMouseEventArgs e) { if (current_local_editor != nullptr) { } else { auto tool = GetActiveTool(); if (tool != nullptr) tool->OnMouseDown(e); } }
LRESULT CALLBACK MyFunc( HWND h, UINT msg, WPARAM w, LPARAM p ) { HDC dc; PAINTSTRUCT ps; int x = ( ( int )( short )LOWORD( p ) ), y = ( ( int )( short )HIWORD( p ) ); switch ( msg ) { case WM_KEYUP: if ( w == 27 ) { SendMessage( h, WM_DESTROY, 0, 0 ); } // OnKeyUp( w ); break; case WM_KEYDOWN: OnKeyDown( w ); break; case WM_LBUTTONDOWN: SetCapture( h ); OnMouseDown( 0, x, y ); break; case WM_MOUSEMOVE: OnMouseMove( x, y ); break; case WM_LBUTTONUP: OnMouseUp( 0, x, y ); ReleaseCapture(); break; case WM_DESTROY: PostQuitMessage( 0 ); break; case WM_PAINT: OnDrawFrame(); dc = BeginPaint( h, &ps ); // transfer the g_FrameBuffer to the hTmpBmp SetDIBits( hMemDC, hTmpBmp, 0, ImageHeight, g_FrameBuffer, &BitmapInfo, DIB_RGB_COLORS ); SelectObject( hMemDC, hTmpBmp ); // Copying the offscreen buffer to the window surface BitBlt( dc, 0, 0, ImageWidth, ImageHeight, hMemDC, 0, 0, SRCCOPY ); EndPaint( h, &ps ); break; case WM_TIMER: InvalidateRect( h, NULL, 1 ); break; } return DefWindowProc( h, msg, w, p ); }
bool WindowSDL::Update() { if(_is_destroyed) return false; SDL_Event e; while(SDL_PollEvent(&e)) { if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_CLOSE) _is_destroyed = true; else if(e.type == SDL_KEYDOWN || e.type == SDL_KEYUP) OnKey(ToKeyEvent(e.type, e.key.keysym)); else if(e.type == SDL_MOUSEBUTTONUP) { switch(e.button.button) { case SDL_BUTTON_LEFT: OnMouseUp(1); break; case SDL_BUTTON_RIGHT: OnMouseUp(2); break; case SDL_BUTTON_MIDDLE: OnMouseUp(3); break; } } else if(e.type == SDL_MOUSEBUTTONDOWN) { switch(e.button.button) { case SDL_BUTTON_LEFT: OnMouseDown(1); break; case SDL_BUTTON_RIGHT: OnMouseDown(2); break; case SDL_BUTTON_MIDDLE: OnMouseDown(3); break; } } else if(e.type == SDL_MOUSEMOTION) { OnMouseMove(e.motion.x, e.motion.y); } } return !_is_destroyed; }
bool Camera::HandleWindowsMessage(UINT message, WPARAM wParam, LPARAM lParam) { (void)lParam; switch (message) { case WM_LBUTTONDOWN: OnMouseDown(MBUTTON_Left); return true; case WM_MBUTTONDOWN: OnMouseDown(MBUTTON_Middle); return true; case WM_RBUTTONDOWN: OnMouseDown(MBUTTON_Right); return true; case WM_LBUTTONUP: OnMouseUp(MBUTTON_Left); return true; case WM_MBUTTONUP: OnMouseUp(MBUTTON_Middle); return true; case WM_RBUTTONUP: OnMouseUp(MBUTTON_Right); return true; case WM_MOUSEWHEEL: OnMouseWheel(int(short(HIWORD(wParam)))); return true; default: return false; } }
LRESULT Framework::EventosEngine(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_KEYDOWN: { input->SetTeclaPressionada((unsigned int)wParam); } break; case WM_KEYUP: { input->SetTeclaSolta((unsigned int)wParam); } break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_SIZE: { JANELA_WIDTH = LOWORD(lParam); JANELA_HEIGHT = HIWORD(lParam); if (md3dDevice) if (wParam == SIZE_RESTORED) if (!mResizing) OnResize(); } default: return DefWindowProc(hwnd, message, wParam, lParam); break; } return 0; }
/** * @brief ウィンドウに関連づけられてるクラスインスタンスが生成できた場合に行う * 実際のウィンドウプロシージャ処理です */ LRESULT CSplitBase::MainProc(UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_LBUTTONDOWN: OnMouseDown((int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam)); break; case WM_MOUSEMOVE: OnMouseMove((int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam)); break; case WM_LBUTTONUP: OnMouseUp((int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam)); break; default: return DefWindowProc(m_hWnd,msg,wParam,lParam); } return false; }
//---------------------------------------------------------------------------- bool FreeFormDeformation::OnMouseClick (int button, int state, int x, int y, unsigned int) { if (mDoRandom || button != MOUSE_LEFT_BUTTON) { return false; } if (state == MOUSE_DOWN) { mMouseDown = true; OnMouseDown(x, y); } else { mMouseDown = false; } return true; }
LRESULT CALLBACK MyFunc( HWND h, UINT msg, WPARAM w, LPARAM p ) { int x = ( ( int )( short )LOWORD( p ) ), y = ( ( int )( short )HIWORD( p ) ); float Xf = ( float )x / ( float )WindowW; float Yf = ( float )y / ( float )WindowH; switch ( msg ) { case WM_KEYUP: OnKey( w, false ); if ( w == 27 ) { SendMessage( h, WM_DESTROY, 0, 0 ); } break; case WM_KEYDOWN: OnKey( w, true ); break; case WM_LBUTTONDOWN: SetCapture( h ); OnMouseDown( 0, LVector2( Xf, Yf ) ); break; case WM_MOUSEMOVE: OnMouseMove( LVector2( Xf, Yf ) ); break; case WM_LBUTTONUP: OnMouseUp( 0, LVector2( Xf, Yf ) ); ReleaseCapture(); break; case WM_DESTROY: PostQuitMessage( 0 ); break; } return DefWindowProc( h, msg, w, p ); }
bool MouseListener::trigger(Event* _event) { switch (_event->getParam()) { case MET_LBDOWN: if (OnMouseDown) return OnMouseDown(_event); break; case MET_LBUP: if (OnMouseUp) return OnMouseUp(_event); break; case MET_MOVE: if (OnMouseMove) return OnMouseMove(_event); break; default: break; } return false; }
XU32 XHTMLButton::Handle(XU32 nOpera, XU32 pData1, XU32 pData2) { if(!IsVisiable()) return 0; switch(nOpera) { case XDO_SELECT: return (XU32)XDomItem::SelectItem((SELECTMARK*)pData1); case XDO_HITTEST: { XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight); if(rect.PtInRect(pData1,pData2)) return (XU32)this; } return 0; case XDO_GET_STYLE: { XU32 s=XDomBlock::Handle(nOpera,pData1,pData2)|DOM_SELECTABLE; return s; }break; case XDO_PAINT: return Paint((DRAWCONTEXT*)pData1); case XDO_EVENT_ONKEYDOWN: if(pData1!=XK_RETURN) break; case XDO_EVENT_ONMOUSEUP: return OnMouseUp((XEVENTDATA*)pData2); case XDO_EVENT_ONMOUSEOUT: return OnMouseLeave((XEVENTDATA*)pData2); case XDO_EVENT_ONMOUSEDOWN: return OnMouseDown(*(XPoint*)pData1,(XEVENTDATA*)pData2); // case XDO_ADD_CHILD: // return XDomNode::Handle(nOpera,pData1,pData2); // case XDO_GET_STYLE: // return XDomInput::Handle(nOpera,pData1,pData2)|DOM_NODE; case XDO_LAYEROUT_CELLS: return LayeroutCells((DRAWCONTEXT*)pData1,(CELLDATA*)pData2); case XDO_LAYEROUT_CELL: return LayeroutCell((DRAWCONTEXT*)pData1,(CELLDATA*)pData2); } return XDomBlock::Handle(nOpera,pData1,pData2); }
LRESULT DXApp::MsgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_KEYDOWN: KeyDown(wParam); return 0; case WM_KEYUP: KeyUp(wParam); return 0; } return DefWindowProc(hWnd, message, wParam, lParam); }
LRESULT CDayPlanSlider::ComponentProc(unsigned int msg, WPARAM wParam, LPARAM lParam) { switch(msg) { // case WM_CREATE: // OnCreate(); // break; case WM_MOUSEMOVE: if(m_bDown)OnMouseMove(lParam); else return DefWindowProc(m_parentHwnd, msg, wParam, lParam); break; case WM_LBUTTONUP: if(m_bDown) { ReleaseCapture(); m_bDown = false; } break; case WM_LBUTTONDOWN: OnMouseDown(LOWORD(lParam), HIWORD(lParam)); break; // case WM_PAINT: // OnPaint(); // break; // case WM_SIZE: // OnSize(LOWORD(lParam), HIWORD(lParam)); // break; /* case WM_DESTROY: OnDestroy(); break; case WM_CLOSE: if(m_ref > 2)break; */ default: return DefWindowProc(m_parentHwnd, msg, wParam, lParam); } return 0; }
void CCodeView::OnMouseMove(wxMouseEvent& event) { wxRect rc = GetClientRect(); if (event.m_leftDown && event.m_x > 16) { if (event.m_y < 0) { m_curAddress -= m_align; Refresh(); } else if (event.m_y > rc.height) { m_curAddress += m_align; Refresh(); } else { OnMouseDown(event); } } event.Skip(); }
LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_SETCURSOR && LOWORD(lParam) == HTCLIENT && !mCursorOn) { SetCursor(NULL); return TRUE; } switch( msg ) { // WM_ACTIVATE is sent when the window is activated or deactivated. // We pause the game when the window is deactivated and unpause it // when it becomes active. case WM_ACTIVATE: if( LOWORD(wParam) == WA_INACTIVE ) { mAppPaused = true; mTimer.Stop(); } else { mAppPaused = false; mTimer.Start(); } return 0; // WM_SIZE is sent when the user resizes the window. case WM_SIZE: // Save the new client area dimensions. mClientWidth = LOWORD(lParam); mClientHeight = HIWORD(lParam); if( md3dDevice ) { if( wParam == SIZE_MINIMIZED ) { if (mFullScreen)mSwapChain->SetFullscreenState(false, NULL); mAppPaused = true; mMinimized = true; mMaximized = false; } else if( wParam == SIZE_MAXIMIZED ) { if (mFullScreen)mSwapChain->SetFullscreenState(true, NULL); mAppPaused = false; mMinimized = false; mMaximized = true; OnResize(); } else if( wParam == SIZE_RESTORED ) { // Restoring from minimized state? if( mMinimized ) { if(mFullScreen)mSwapChain->SetFullscreenState(true, NULL); mAppPaused = false; mMinimized = false; OnResize(); } // Restoring from maximized state? else if( mMaximized ) { mAppPaused = false; mMaximized = false; OnResize(); } else if( mResizing ) { // If user is dragging the resize bars, we do not resize // the buffers here because as the user continuously // drags the resize bars, a stream of WM_SIZE messages are // sent to the window, and it would be pointless (and slow) // to resize for each WM_SIZE message received from dragging // the resize bars. So instead, we reset after the user is // done resizing the window and releases the resize bars, which // sends a WM_EXITSIZEMOVE message. } else // API call such as SetWindowPos or mSwapChain->SetFullscreenState. { OnResize(); } } } return 0; // WM_EXITSIZEMOVE is sent when the user grabs the resize bars. case WM_ENTERSIZEMOVE: mAppPaused = true; mResizing = true; mTimer.Stop(); return 0; // WM_EXITSIZEMOVE is sent when the user releases the resize bars. // Here we reset everything based on the new window dimensions. case WM_EXITSIZEMOVE: mAppPaused = false; mResizing = false; mTimer.Start(); OnResize(); return 0; // WM_DESTROY is sent when the window is being destroyed. case WM_DESTROY: PostQuitMessage(0); return 0; // The WM_MENUCHAR message is sent when a menu is active and the user presses // a key that does not correspond to any mnemonic or accelerator key. case WM_MENUCHAR: // Don't beep when we alt-enter. return MAKELRESULT(0, MNC_CLOSE); // Catch this message so to prevent the window from becoming too small. case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; return 0; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_KEYUP: OnKeyUP(wParam); if (wParam == VK_ESCAPE) { PostQuitMessage(0); return 0; } break; } return DefWindowProc(hwnd, msg, wParam, lParam); }
void GUIControl::Process() { __super::Process(); if(IsVisible() && IsEnabled()) { if(PointInBox(mouseX, mouseY, GetX(), GetY(), GetWidth(), GetHeight())) { int cursor = GetLastCursorPos(); SetLastCursorPos(1); // mouse is in // here // 0 - init // 1 - mouse was IN control // 2 - mouse was OUT control if(cursor == 0 || cursor == 2) { OnMouseEnter(); } else { OnMouseMove(); } if(mouse[0] || mouse[1]) { if(GetLastPressState() == 0) { OnMouseDown(); if(mouse[0]) SetLastPressState(1); else if(mouse[1]) SetLastPressState(2); } } else { int press_state = GetLastPressState(); SetLastPressState(0); // here // 0 - init // 1 - left mouse down // 2 - right mouse down // 3 - all up if(press_state == 1) { OnLeftClick(); OnMouseUp(); } else if(press_state == 2) { OnRightClick(); OnMouseUp(); } } } else { int cursor = GetLastCursorPos(); SetLastCursorPos(2); // mouse is out if(cursor == 1) { OnMouseLeave(); SetLastPressState(0); } } // TODO: // fix it somehow :( if(IsFocused()) { static UCHAR count = 0; int delay = 0; for(UCHAR i = 0; i < 255; i++) { if(GetAsyncKeyState(i) & 0x8000) { count++; static int prev; count == 1 ? delay = KEY_FIRST_DELAY : delay = KEY_DELAY; if(current_time - prev >= delay) { if(i != VK_SHIFT) { OnKeyDown(i); prev = current_time; } } } } } } }
void CModifiedButtonWidget::OnMouseEvent( CMouseEvent* event ) { // logger << event->GetButtons() << std::endl; switch( event->GetType() ) { case types::mouse_button_down: if( event->GetButtons() & myClickableButtons ) { mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_down" ); myClicked = true; OnMouseDown( myParam ); } if( myDragable && event->GetButtons() & myDragableButtons ) { // mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" ); myDragging = true; myDragOffset = types::point( this->GetRect().x, this->GetRect().y ) - event->GetPosition(); IMouse::AddConstantEventListeners( this ); } if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == true ) { if( myDoubleClickTimer.GetTime() < double_click_time ) OnDoubleClick( myParam ); myDoubleClicking = false; } else if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == false ) { myDoubleClickTimer.Reset(); myDoubleClickTimer.Resume(); myDoubleClicking = true; } else if ( myDoubleClickable && event->GetButtons() & !myDoubleClickableButtons ) { myDoubleClicking = false; } break; case types::mouse_button_up: if( myClicked && event->GetButtons() & myClickableButtons ) { mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_up" ); OnClick( myParam ); myClicked = false; OnMouseUp( myParam ); } if( myDragable && event->GetButtons() & myDragableButtons ) { // mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" ); myDragging = false; IMouse::RemoveConstantEventListeners( this ); OnDragEnd(); } myClicked = false; break; case types::mouse_move: if( myDragging ) { types::point where_to = event->GetPosition() + myDragOffset; // Fixed 12-09-2007 by Pete //-------------------------------------------------------------------------- // BUGBUG: This should be the commented line, but the signal-slot // doesn't support three parameters at the current time // OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam ); if( config::automatic_dragging ) MoveBy( types::point( where_to.x - GetRect().x, where_to.y - GetRect().y ) ); OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam ); } // myDoubleClicking = false; break; case types::mouse_over: { const std::string animation = mySelectionOn?"select_mouse_over":"mouse_over"; mySpriteHandler->PlayAnimation( GetSprite(), animation ); OnMouseOver( myParam ); } break; case types::mouse_out: { const std::string animation = mySelectionOn?"select_mouse_out":"mouse_out"; mySpriteHandler->PlayAnimation( GetSprite(), animation ); myClicked = false; myDoubleClicking = false; OnMouseOut( myParam ); } break; default: break; } }
void StyledCheckBox::OnMouseDoubleClick(wxMouseEvent& mouseEvent) { OnMouseDown(mouseEvent); }
bool TopWindow::OnEvent(const SDL_Event &event) { switch (event.type) { Window *w; #if SDL_MAJOR_VERSION < 2 case SDL_VIDEOEXPOSE: invalidated = false; Expose(); return true; #endif case SDL_KEYDOWN: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; #if SDL_MAJOR_VERSION >= 2 return w->OnKeyDown(event.key.keysym.sym); #else return w->OnKeyDown(event.key.keysym.sym) || (event.key.keysym.unicode != 0 && w->OnCharacter(event.key.keysym.unicode)); #endif #if SDL_MAJOR_VERSION >= 2 case SDL_TEXTINPUT: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; if (event.text.text && *event.text.text) { std::pair<unsigned, const char *> next = NextUTF8(event.text.text); bool handled = w->OnCharacter(next.first); while (next.second) { next = NextUTF8(next.second); handled = w->OnCharacter(next.first) || handled; } return handled; } else return false; #endif case SDL_KEYUP: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; return w->OnKeyUp(event.key.keysym.sym); #ifdef HAVE_MULTI_TOUCH case SDL_FINGERDOWN: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 2) return OnMultiTouchDown(); else return false; case SDL_FINGERUP: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 1) return OnMultiTouchUp(); else return false; #endif case SDL_MOUSEMOTION: // XXX keys return OnMouseMove(event.motion.x, event.motion.y, 0); case SDL_MOUSEBUTTONDOWN: #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP) return OnMouseWheel(event.button.x, event.button.y, 1); else if (event.button.button == SDL_BUTTON_WHEELDOWN) return OnMouseWheel(event.button.x, event.button.y, -1); #endif return double_click.Check(RasterPoint(event.button.x, event.button.y)) ? OnMouseDouble(event.button.x, event.button.y) : OnMouseDown(event.button.x, event.button.y); case SDL_MOUSEBUTTONUP: #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP || event.button.button == SDL_BUTTON_WHEELDOWN) /* the wheel has already been handled in SDL_MOUSEBUTTONDOWN */ return false; #endif double_click.Moved(RasterPoint(event.button.x, event.button.y)); return OnMouseUp(event.button.x, event.button.y); case SDL_QUIT: return OnClose(); #if SDL_MAJOR_VERSION < 2 case SDL_VIDEORESIZE: Resize(event.resize.w, event.resize.h); return true; #endif #if SDL_MAJOR_VERSION >= 2 case SDL_MOUSEWHEEL: int x, y; SDL_GetMouseState(&x, &y); return OnMouseWheel(x, y, event.wheel.y); case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_RESIZED: Resize(event.window.data1, event.window.data2); return true; case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_MAXIMIZED: { SDL_Window* event_window = SDL_GetWindowFromID(event.window.windowID); if (event_window) { int w, h; SDL_GetWindowSize(event_window, &w, &h); if ((w >= 0) && (h >= 0)) { Resize(w, h); } } } return true; case SDL_WINDOWEVENT_EXPOSED: invalidated = false; Expose(); return true; } #endif } return false; }
void UIElement::CheckInput() { if (interactive) { int mouseX, mouseY; App->input->GetMousePosition(mouseX, mouseY); int elementX = GetWorldRect().x; int elementY = GetWorldRect().y; if (App->gui->debugMode) { int colX = GetWorldRect().x; int colY = GetWorldRect().y; App->render->DrawQuad(SDL_Rect{ colX - App->render->camera.x, colY - App->render->camera.y, collider.w, collider.h }, 255, 0, 0, 50, false); } if (mouseX > elementX && mouseX < elementX + collider.w && mouseY >elementY && mouseY < elementY + collider.h) { if (!mouseWasIn) { //LOG("%s - Mouse Enter", name.GetString()); mouseWasIn = true; App->gui->SetHovering(this); OnMouseEnter(); if (listener) { listener->OnGUI(MOUSE_ENTER, this); } App->gui->inputRecieved = true; } if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_DOWN) { //LOG("%s - Mouse Down", name.GetString()); mouseWasClicked = true; OnMouseDown(); if (listener) { listener->OnGUI(MOUSE_DOWN, this); } App->gui->inputRecieved = true; App->gui->SetFocus(this); } else if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_UP) { if (mouseWasClicked) { //LOG("%s - Mouse Up", name.GetString()); mouseWasClicked = false; OnMouseUp(); if (listener) { listener->OnGUI(MOUSE_UP, this); } App->gui->inputRecieved = true; } else if (App->gui->GetFocus()) { if(App->gui->GetFocus()->mouseWasClicked) { App->gui->GetFocus()->OnMouseUp(); } } } } else { // if (mouseWasClicked) // mouseWasClicked = false; if (mouseWasIn) { //LOG("%s - Mouse Exit", name.GetString()); mouseWasIn = false; OnMouseExit(); App->gui->SetHovering(NULL); if (listener) { listener->OnGUI(MOUSE_EXIT, this); } App->gui->inputRecieved = true; } } if (App->gui->GetFocus() == this) { if (App->input->GetKey(SDL_SCANCODE_RETURN) == KEY_DOWN) { //LOG("%s - Return down", name.GetString()); if (listener) { listener->OnGUI(RETURN_DOWN, this); } } } } }
// -------------------------------------------------------- // Handles messages that are sent to our window by the // operating system. Ignoring these messages would cause // our program to hang and Windows would think it was // unresponsive. // -------------------------------------------------------- LRESULT DirectXGameCore::ProcessMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch( msg ) { case WM_ACTIVATEAPP: DirectX::Keyboard::ProcessMessage(msg, wParam, lParam); DirectX::Mouse::ProcessMessage(msg, wParam, lParam); return 0; case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: DirectX::Keyboard::ProcessMessage(msg, wParam, lParam); return 0; // WM_ACTIVATE is sent when the window is activated or deactivated. // We're using this to keep track of focus, if that's useful to you. case WM_ACTIVATE: if( LOWORD(wParam) == WA_INACTIVE ) { hasFocus = false; } else { hasFocus = true; } return 0; // WM_SIZE is sent when the user resizes the window. case WM_SIZE: // Save the new client area dimensions. windowWidth = LOWORD(lParam); windowHeight = HIWORD(lParam); if( device ) { if( wParam == SIZE_MINIMIZED ) { hasFocus = false; minimized = true; maximized = false; } else if( wParam == SIZE_MAXIMIZED ) { hasFocus = true; minimized = false; maximized = true; OnResize(); } else if( wParam == SIZE_RESTORED ) { // Restoring from minimized state? if( minimized ) { hasFocus = true; minimized = false; OnResize(); } // Restoring from maximized state? else if( maximized ) { hasFocus = true; maximized = false; OnResize(); } else if( resizing ) { // If user is dragging the resize bars, we do not resize // the buffers here because as the user continuously // drags the resize bars, a stream of WM_SIZE messages are // sent to the window, and it would be pointless (and slow) // to resize for each WM_SIZE message received from dragging // the resize bars. So instead, we reset after the user is // done resizing the window and releases the resize bars, which // sends a WM_EXITSIZEMOVE message. } else // API call such as SetWindowPos or mSwapChain->SetFullscreenState. { OnResize(); } } } return 0; // WM_EXITSIZEMOVE is sent when the user grabs the resize bars. case WM_ENTERSIZEMOVE: resizing = true; return 0; // WM_EXITSIZEMOVE is sent when the user releases the resize bars. // Here we reset everything based on the new window dimensions. case WM_EXITSIZEMOVE: resizing = false; OnResize(); return 0; // WM_DESTROY is sent when the window is being destroyed. case WM_DESTROY: PostQuitMessage(0); return 0; // The WM_MENUCHAR message is sent when a menu is active and the user presses // a key that does not correspond to any mnemonic or accelerator key. case WM_MENUCHAR: // Don't beep when we alt-enter. return MAKELRESULT(0, MNC_CLOSE); // Catch this message so to prevent the window from becoming too small. case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; return 0; // Messages that correspond to mouse button being pressed while the cursor // is currently over our window case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); DirectX::Mouse::ProcessMessage(msg, wParam, lParam); return 0; // Messages that correspond to mouse button being released while the cursor // is currently over our window case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); DirectX::Mouse::ProcessMessage(msg, wParam, lParam); return 0; // Message that occurs while the mouse moves over the window or while // we're currently capturing it case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); // fall through case WM_MOUSEWHEEL: case WM_INPUT: case WM_MOUSEHOVER: case WM_XBUTTONDOWN: case WM_XBUTTONUP: DirectX::Mouse::ProcessMessage(msg, wParam, lParam); return 0; } // Some other message was sent, so call the default window procedure for it return DefWindowProc(hwnd, msg, wParam, lParam); }
void ISwitchControl::OnMouseDblClick(int x, int y, IMouseMod* pMod) { OnMouseDown(x, y, pMod); }
LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { // WM_ACTIVATE is sent when the window is activated or deactivated. // We pause the game when the window is deactivated and unpause it // when it becomes active. case WM_ACTIVATE: { if (LOWORD(wParam) == WA_INACTIVE) { mAppPaused = true; mTimer.Stop(); } else { mAppPaused = false; mTimer.Start(); } return 0; } // WM_SIZE is sent when the user resizes the window. case WM_SIZE: { // Save the new client area dimensions. mClientWidth = LOWORD(lParam); mClientHeight = HIWORD(lParam); if (mDevice) { if (wParam == SIZE_MINIMIZED) { mAppPaused = true; mMinimized = true; mMaximized = false; } else if (wParam == SIZE_MAXIMIZED) { mAppPaused = false; mMinimized = false; mMaximized = true; OnResize(); } else if (wParam == SIZE_RESTORED) { // Restoring from minimized state? if (mMinimized) { mAppPaused = false; mMinimized = false; OnResize(); } // Restoring from maximized state? else if (mMaximized) { mAppPaused = false; mMaximized = false; OnResize(); } else // API call such as SetWindowPos or mSwapChain->SetFullscreenState. { OnResize(); } } } return 0; } // WM_EXITSIZEMOVE is sent when the user grabs the resize bars. case WM_ENTERSIZEMOVE: { mAppPaused = true; mTimer.Stop(); return 0; } // WM_EXITSIZEMOVE is sent when the user releases the resize bars. // Here we reset everything based on the new window dimensions. case WM_EXITSIZEMOVE: { mAppPaused = false; mTimer.Start(); OnResize(); return 0; } // WM_DESTROY is sent when the window is being destroyed. case WM_DESTROY: { PostQuitMessage(0); return 0; } // The WM_MENUCHAR message is sent when a menu is active and the user presses // a key that does not correspond to any mnemonic or accelerator key. case WM_MENUCHAR: { // Don't beep when we alt-enter. return MAKELRESULT(0, MNC_CLOSE); } // Catch this message so to prevent the window from becoming too small. case WM_GETMINMAXINFO: { ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; return 0; } case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_CHAR: OnKeyDown(wParam, lParam); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); }