LRESULT Window::wndProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: { if (onCreate()) break; return 0; } case WM_DESTROY: { if (onDestroy()) break; return 0; } case WM_CLOSE: { if (onClose()) break; return 0; } case WM_MOUSEMOVE: { if (onMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) break; return 0; } case WM_LBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0)) break; return 0; } case WM_RBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 1)) break; return 0; } case WM_MBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 2)) break; return 0; } case WM_LBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0)) break; return 0; } case WM_RBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 1)) break; return 0; } case WM_MBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 2)) break; return 0; } case WM_PAINT: { if (onPaint()) break; return 0; } case WM_SIZE: { if (onSizeChanged()) break; return 0; } case WM_KEYDOWN: { if (onKeyDown((UINT)wParam)) break; return 0; } case WM_KEYUP: { if (onKeyUp((UINT)wParam)) break; return 0; } case WM_COMMAND: { if (SendMessage(reinterpret_cast<HWND>(lParam), WM_COMMAND_REFLECT, wParam, lParam)) break; return 0; } } if (mBaseWndProc != sGlobalWndProc) { LRESULT r = CallWindowProc(mBaseWndProc, mHWND, uMsg, wParam, lParam); return r; } else { LRESULT r = DefWindowProc(mHWND, uMsg, wParam, lParam); return r; } }
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; }
bool EventListenerMouse::init() { auto listener = [this](Event* event){ auto mouseEvent = static_cast<EventMouse*>(event); switch (mouseEvent->_mouseEventType) { case EventMouse::MouseEventType::MOUSE_DOWN: if(onMouseDown != nullptr) onMouseDown(event); break; case EventMouse::MouseEventType::MOUSE_UP: if(onMouseUp != nullptr) onMouseUp(event); break; case EventMouse::MouseEventType::MOUSE_MOVE: if(onMouseMove != nullptr) onMouseMove(event); break; case EventMouse::MouseEventType::MOUSE_SCROLL: if(onMouseScroll != nullptr) onMouseScroll(event); break; default: break; } }; if (EventListener::init(Type::MOUSE, static_cast<ListenerID>(Type::MOUSE), listener)) { return true; } return false; }
// Simple main loop void mainLoop() { // Window is not minimized bool active = true; for(;;)// Infinite loop { SDL_Event event; // Wait for event if(SDL_WaitEvent(&event) == 0) throw SDL_Exception(); // Screen needs redraw bool redraw = false; // Handle all waiting events do { camera += cam_velocity; // Call proper event handlers switch(event.type) { case SDL_ACTIVEEVENT : // Stop redraw when minimized if(event.active.state == SDL_APPACTIVE) active = event.active.gain; break; case SDL_KEYDOWN : onKeyDown(event.key.keysym.sym, event.key.keysym.mod); break; case SDL_KEYUP : onKeyUp(event.key.keysym.sym, event.key.keysym.mod); break; case SDL_MOUSEMOTION : onMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, event.motion.state); break; case SDL_MOUSEBUTTONDOWN : onMouseDown(event.button.button, event.button.x, event.button.y); break; case SDL_MOUSEBUTTONUP : onMouseUp(event.button.button, event.button.x, event.button.y); break; case SDL_QUIT : return; // End main loop case SDL_VIDEORESIZE : onWindowResized(event.resize.w, event.resize.h); break; case SDL_VIDEOEXPOSE : redraw = true; break; default : // Do nothing break; } } while(SDL_PollEvent(&event) == 1); // Optionally redraw window if(active && redraw) onWindowRedraw(); } }
/*-------------------------------------------------------------------------*/ LRESULT CALLBACK NHCommandWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PNHCmdWindow data; int i; switch (message) { case WM_CREATE: onCreate( hWnd, wParam, lParam ); break; case WM_PAINT: onPaint(hWnd); break; case WM_SIZE: LayoutCmdWindow(hWnd); break; case WM_LBUTTONDOWN: onMouseDown(hWnd, wParam, lParam); return 0; case WM_MOUSEMOVE: /* proceed only if if have mouse focus (set in onMouseDown() - left mouse button is pressed) */ if( GetCapture()==hWnd ) { onMouseMove(hWnd, wParam, lParam); return 0; } else { return 1; } break; case WM_LBUTTONUP: /* proceed only if if have mouse focus (set in onMouseDown()) */ if( GetCapture()==hWnd ) { onMouseUp(hWnd, wParam, lParam); return 0; } else { return 1; } break; case WM_DESTROY: data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA); for(i=0; i<=NH_CMDPAD_FONT_MAX; i++ ) if( data->font[i] ) DeleteObject(data->font[i]); free(data); SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return FALSE; }
void Widget::handleEvents(void) { if(dumb) return; bool lastWithin = hover; bool lastMouseDown = mouseDown; mouseDown = g_Input.MouseLeft; within = isWithin(); // Mouse Enter if(within && !lastWithin) { hover = true; onMouseEnter(); } // Mouse Exit if(!within && lastWithin) { hover = false; onMouseExit(); } g_GUI.mouseOverSomeWidget |= hover; // Mouse Up if(!mouseDown && lastMouseDown) { if(hover) { onMouseUp(); // Click if(depressed && !g_GUI.clickAlreadyProcessedThisTick) { g_GUI.clickAlreadyProcessedThisTick = true; // top-most widgets are updated first anyway g_SoundSystem.play("data/sound/click.wav"); onMouseClick(); } } depressed = false; } // Mouse Down if(hover && mouseDown) { depressed = true; if(!lastMouseDown) { onMouseDown(); } } }
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 ZVision::processEvents() { while (_eventMan->pollEvent(_event)) { switch (_event.type) { case Common::EVENT_LBUTTONDOWN: onMouseDown(_event.mouse); break; case Common::EVENT_LBUTTONUP: onMouseUp(_event.mouse); break; case Common::EVENT_RBUTTONDOWN: // TODO: Inventory logic break; case Common::EVENT_MOUSEMOVE: onMouseMove(_event.mouse); break; case Common::EVENT_KEYDOWN: switch (_event.kbd.keycode) { case Common::KEYCODE_d: if (_event.kbd.hasFlags(Common::KBD_CTRL)) { // Start the debugger _console->attach(); _console->onFrame(); } break; case Common::KEYCODE_q: if (_event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); break; default: break; } _scriptManager->onKeyDown(_event.kbd); break; case Common::EVENT_KEYUP: _scriptManager->onKeyUp(_event.kbd); break; default: break; } } }
void Game::handleEvent( const SDL_Event& e ) { switch( e.type ) { case SDL_QUIT: running_ = false; break; case SDL_KEYDOWN: onKeyDown( e.key.keysym.sym ); break; case SDL_KEYUP: onKeyUp( e.key.keysym.sym ); break; case SDL_MOUSEBUTTONDOWN: int x, y; SDL_GetMouseState( &x, &y ); onMouseDown( Vec2( x, y ) ); break; } }
void SDL_GUI::GUI_Element::Update() { bool inRect = rect.Contains(inputManager->GetMousePosition()); if (!mouseIsOver && inRect) { mouseIsOver = true; if (onMouseOver != NULL) onMouseOver(); } else if (mouseIsOver && !inRect) { mouseIsOver = false; performingClick = false; if (onMouseOut != NULL) onMouseOut(); } if (inRect) { if (inputManager->MouseDown()) { performingClick = true; if (onMouseDown != NULL) onMouseDown(); } else if (inputManager->MouseUp()) { if (onMouseUp != NULL) onMouseUp(); if (performingClick) { performingClick = false; if (onClick != NULL) onClick(); } } } }
void CButton::onEvent(Uint8 eventType) { if(!display) return; int mouse_x = event.button.x; int mouse_y = event.button.y; if(onButton(mouse_x, mouse_y)) { if(eventType == SDL_MOUSEBUTTONDOWN) onMouseDown(); else if(eventType == SDL_MOUSEBUTTONUP) onClick(); else if(eventType == SDL_MOUSEMOTION) onMouseOver(); } else setImageState(getType()); }
void InputHandler::handleEvents() { SDL_Event event; while (SDL_PollEvent(&event)) { keyState = SDL_GetKeyboardState(nullptr); switch (event.type) { case SDL_QUIT: quit = true; break; case SDL_MOUSEBUTTONDOWN: onMouseDown(event); break; case SDL_MOUSEBUTTONUP: onMouseUp(event); break; case SDL_TEXTINPUT: onTextInput(event); break; } } }
void CtrlMemView::onMouseMove(WPARAM wParam, LPARAM lParam, int button) { if (button&1) { int x = LOWORD(lParam); int y = (signed short)HIWORD(lParam); if (x>16) { if (y<0) { curAddress-=align*alignMul; redraw(); } else if (y>rect.bottom) { curAddress+=align*alignMul; redraw(); } else onMouseDown(wParam,lParam,1); } } }
void CtrlRegisterList::onMouseMove(WPARAM wParam, LPARAM lParam, int button) { if (button&1) { int x = LOWORD(lParam); int y = (signed short)HIWORD(lParam); // if (x>16) { /* if (y<0) { curAddress-=align; redraw(); } else if (y>rect.bottom) { curAddress+=align; redraw(); } else*/ onMouseDown(wParam,lParam,1); } } }
Common::Error ComposerEngine::run() { Common::Event event; _vars.resize(1000); for (uint i = 0; i < _vars.size(); i++) _vars[i] = 0; _queuedScripts.resize(10); for (uint i = 0; i < _queuedScripts.size(); i++) { _queuedScripts[i]._count = 0; _queuedScripts[i]._scriptId = 0; } if (!_bookIni.loadFromFile("book.ini")) { _directoriesToStrip = 0; if (!_bookIni.loadFromFile("programs/book.ini")) { // mac version? if (!_bookIni.loadFromFile("Darby the Dragon.ini")) if (!_bookIni.loadFromFile("Gregory.ini")) error("failed to find book.ini"); } } uint width = 640; if (_bookIni.hasKey("Width", "Common")) width = atoi(getStringFromConfig("Common", "Width").c_str()); uint height = 480; if (_bookIni.hasKey("Height", "Common")) height = atoi(getStringFromConfig("Common", "Height").c_str()); initGraphics(width, height, true); _screen.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor(); CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor()); CursorMan.replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount()); delete cursor; _console = new Console(this); loadLibrary(0); uint fps = atoi(getStringFromConfig("Common", "FPS").c_str()); uint frameTime = 125; // Default to 125ms (1000/8) if (fps != 0) frameTime = 1000 / fps; else warning("FPS in book.ini is zero. Defaulting to 8..."); uint32 lastDrawTime = 0; while (!shouldQuit()) { for (uint i = 0; i < _pendingPageChanges.size(); i++) { if (_pendingPageChanges[i]._remove) unloadLibrary(_pendingPageChanges[i]._pageId); else loadLibrary(_pendingPageChanges[i]._pageId); lastDrawTime = _system->getMillis(); } _pendingPageChanges.clear(); uint32 thisTime = _system->getMillis(); // maintain our own internal timing, since otherwise we get // confused when starved of CPU (for example when the user // is dragging the scummvm window around) if (thisTime > _lastTime + frameTime) _currentTime += frameTime; else _currentTime += thisTime - _lastTime; _lastTime = thisTime; for (uint i = 0; i < _queuedScripts.size(); i++) { QueuedScript &script = _queuedScripts[i]; if (!script._count) continue; if (script._baseTime + script._duration > _currentTime) continue; if (script._count != 0xffffffff) script._count--; script._baseTime = _currentTime; runScript(script._scriptId, i, 0, 0); } if (lastDrawTime + frameTime <= thisTime) { // catch up if we're more than 2 frames behind if (lastDrawTime + (frameTime * 2) <= thisTime) lastDrawTime = thisTime; else lastDrawTime += frameTime; redraw(); tickOldScripts(); processAnimFrame(); } else if (_needsUpdate) { redraw(); } while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_LBUTTONDOWN: onMouseDown(event.mouse); break; case Common::EVENT_LBUTTONUP: break; case Common::EVENT_RBUTTONDOWN: break; case Common::EVENT_MOUSEMOVE: onMouseMove(event.mouse); break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { case Common::KEYCODE_d: if (event.kbd.hasFlags(Common::KBD_CTRL)) { // Start the debugger getDebugger()->attach(); getDebugger()->onFrame(); } break; case Common::KEYCODE_q: if (event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); break; default: break; } onKeyDown(event.kbd.keycode); break; default: break; } } _system->delayMillis(20); } _screen.free(); return Common::kNoError; }
void Event::onEvent(SDL_Event *event) { switch (event->type) { case SDL_ACTIVEEVENT: switch (event->active.state) { case SDL_APPMOUSEFOCUS: if (event->active.gain) { onMouseFocus(); } else { onMouseBlur(); } break; case SDL_APPINPUTFOCUS: if (event->active.gain) { onInputFocus(); } else { onInputBlur(); } break; case SDL_APPACTIVE: if (event->active.gain) { onRestore(); } else { onMinimize(); } break; } break; //SDL_ACTIVEEVENT case SDL_KEYDOWN: onKeyDown(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; case SDL_KEYUP: onKeyUp(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; case SDL_MOUSEBUTTONDOWN: onMouseDown(event->button.button, event->button.x, event->button.y); break; case SDL_MOUSEBUTTONUP: onMouseUp(event->button.button, event->button.x, event->button.y); break; case SDL_JOYAXISMOTION: onJoyAxis(event->jaxis.which, event->jaxis.axis, event->jaxis.value); break; case SDL_JOYBALLMOTION: onJoyBall(event->jball.which, event->jball.ball, event->jball.xrel, event->jball.yrel); break; case SDL_JOYHATMOTION: onJoyHat(event->jhat.which, event->jhat.hat, event->jhat.value); break; case SDL_JOYBUTTONDOWN: onJoyButtonDown(event->jbutton.which, event->jbutton.button); break; case SDL_JOYBUTTONUP: onJoyButtonUp(event->jbutton.which, event->jbutton.button); break; case SDL_QUIT: onQuit(); break; case SDL_VIDEORESIZE: onResize(event->resize.w, event->resize.h); break; default: onUser(event->user.type, event->user.code, event->user.data1, event->user.data2); break; } }
void FGIRCNicknames::onRightMouseDown(const Event &event) { onMouseDown(event); }
void callHandlersOnMouseDown(const Mouse& m){ CALL(onMouseDown(m)); }
// Animation main loop // period - maximum time between redraws in ms void mainLoop(unsigned period) { // This main loop requires timer support if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) throw SDL_Exception(); // Create redraw timer class RedrawTimer { private : SDL_TimerID id; static Uint32 callback(Uint32 interval, void *) { redraw(); return interval; } public : RedrawTimer(unsigned interval) : id(SDL_AddTimer(interval, callback, NULL)) { if(id == NULL) throw SDL_Exception(); } ~RedrawTimer() { if(id != NULL) SDL_RemoveTimer(id); } } redrawTimer(period); // Window is not minimized bool active = true; for(;;)// Infinite loop { SDL_Event event; // Wait for event if(SDL_WaitEvent(&event) == 0) throw SDL_Exception(); // Screen needs redraw bool redraw = false; // Handle all waiting events do { // Call proper event handlers switch(event.type) { case SDL_ACTIVEEVENT :// Stop redraw when minimized if(event.active.state == SDL_APPACTIVE) active = event.active.gain; break; case SDL_KEYDOWN : onKeyDown(event.key.keysym.sym, event.key.keysym.mod); break; case SDL_KEYUP : onKeyUp(event.key.keysym.sym, event.key.keysym.mod); break; case SDL_MOUSEMOTION : onMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, event.motion.state); break; case SDL_MOUSEBUTTONDOWN : onMouseDown(event.button.button, event.button.x, event.button.y); break; case SDL_MOUSEBUTTONUP : onMouseUp(event.button.button, event.button.x, event.button.y); break; case SDL_QUIT : return;// End main loop case SDL_VIDEORESIZE : onWindowResized(event.resize.w, event.resize.h); break; case SDL_VIDEOEXPOSE : redraw = true; break; default :// Do nothing break; } } while(SDL_PollEvent(&event) == 1); // Optionally redraw window if(active && redraw) onWindowRedraw(); } }
//----------------------------------------------------------------------------- CMouseEventResult CFrame::platformOnMouseDown (CPoint& where, const CButtonState& buttons) { CollectInvalidRects cir (this); return onMouseDown (where, buttons); }
void Clickable::mouseDown(MouseEvent* mouse_event) { emit onMouseDown(mouse_event); }
LRESULT D3DApp::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) { m_paused = true; m_timer.stop(); } else { m_paused = false; m_timer.start(); } break; case WM_ENTERSIZEMOVE: m_paused = true; m_resizing = true; m_timer.stop(); break; case WM_SIZE: m_clientWidth = LOWORD(lParam); m_clientHeight = HIWORD(lParam); if (m_device) { if (wParam == SIZE_MINIMIZED) { m_paused = true; m_minimized = true; m_maximized = false; } else if (wParam == SIZE_MAXIMIZED) { m_paused = false; m_minimized = false; m_maximized = true; onResize(); } else if (wParam == SIZE_RESTORED) { if (m_minimized) { m_paused = false; m_minimized = false; onResize(); } else if (m_maximized) { m_paused = false; m_maximized = false; onResize(); } else if (m_resizing) { } else { onResize(); } } } break; case WM_EXITSIZEMOVE: m_paused = false; m_resizing = false; m_timer.start(); onResize(); break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: onMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: onMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_INPUT: { UINT dwSize = 40; BYTE lpb[40]; GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)); RAWINPUT* raw = (RAWINPUT*)lpb; if (raw->header.dwType == RIM_TYPEMOUSE) { int dx = raw->data.mouse.lLastX; int dy = raw->data.mouse.lLastY; onMouseMove(dx, dy); } break; } case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; }
bool HippoCanvas::processMessage(UINT message, WPARAM wParam, LPARAM lParam) { if (HippoAbstractControl::processMessage(message, wParam, lParam)) return true; switch (message) { case WM_PAINT: onPaint(wParam, lParam); // do NOT call DefWindowProc, it clears the update region return true; case WM_HSCROLL: if (hscrollNeeded_) { int newX = hscroll_->handleScrollMessage(message, wParam, lParam); scrollTo(newX, canvasY_); } return true; case WM_VSCROLL: case WM_MOUSEWHEEL: // running DefWindowProc for this one forwards it to parent window if (vscrollNeeded_) { int newY = vscroll_->handleScrollMessage(message, wParam, lParam); scrollTo(canvasX_, newY); } return true; case WM_SETCURSOR: // kill DefWindowProc setting the cursor, so we are the only // ones that do (in the mouse move handler) return true; case WM_LBUTTONDOWN: onMouseDown(1, wParam, lParam); return true; case WM_LBUTTONUP: onMouseUp(1, wParam, lParam); return true; case WM_LBUTTONDBLCLK: onMouseDoubleClick(1, wParam, lParam); return true; case WM_MBUTTONDOWN: onMouseDown(2, wParam, lParam); return true; case WM_MBUTTONUP: onMouseUp(2, wParam, lParam); return true; case WM_RBUTTONDOWN: onMouseDown(3, wParam, lParam); return true; case WM_RBUTTONUP: onMouseUp(3, wParam, lParam); return true; case WM_MOUSEMOVE: onMouseMove(wParam, lParam); return true; case WM_MOUSELEAVE: onMouseLeave(wParam, lParam); return true; case WM_MOUSEHOVER: onHover(wParam, lParam); return true; case WM_SETFOCUS: // forward focus on to some control inside the canvas, if any hippo_canvas_context_win_focus_controls(context_); return true; case WM_COMMAND: return onCommand(wParam, lParam); } return false; }
void Widget::process(const WidgetEvents & events) { // check automatic size. if (isAutoManagingWidth() || isAutoManagingHeight()) { sf::Vector2f autoSize = getAutomaticSize(); setSize(isAutoManagingWidth() ? autoSize.x : getSize().x, isAutoManagingHeight() ? autoSize.y : getSize().y); } // clear click flags for all buttons. myIsClicked = 0; // set mouse-over flag. mouse position is already pre-transformed. bool mouseOver = events.mouseFocus && checkMouseover(events.mousePosition); if (myIsMouseOver != mouseOver) { myIsMouseOver = mouseOver; if (mouseOver) { onMouseOver(); } else { onMouseAway(); } } // analyze container events to find state changes. for (auto it = events.conEvents.mouseEvents.begin(); it != events.conEvents.mouseEvents.end(); ++it) { ContainerEvents::MouseEvent event = *it; MouseBitmask buttonMask = convertMouseButtonBitmask(event.button); sf::Vector2f convPos = events.transform.getInverse().transformPoint(event.position); // check if mouse is over widget (and widget is not obstructed). if (events.mouseFocus && checkMouseover(convPos)) { // handle mouse presses/releases on the widget, check for successful click. if (event.isPress) { // bring widget to front on left mouse click. //if (event.button == sf::Mouse::Left) // sendToFront(); // add mouse button to bitmask. myIsMouseDown |= buttonMask; onMouseDown(convPos, event.button); } else if (myIsMouseDown & buttonMask) { myIsClicked |= buttonMask; onClick(convPos, event.button); } } // handle mouse button release. if (!event.isPress) { // remove mouse button from bitmask. if (myIsMouseDown & buttonMask) { myIsMouseDown &= ~buttonMask; onMouseUp(convPos, event.button); } } } // now process widget events. onProcess(events); }