bool InputState::Update()
	{
		bool result = false;
		_backspacePressed = false;
		_text = "";

		_wheelAmount = 0;

		SDL_Event e;
		while (SDL_PollEvent(&e) != 0)
		{
			if (e.type == SDL_QUIT)
				result = true;
			else if (e.type == SDL_MOUSEBUTTONDOWN)
				HandleMouseButtonDown(e);
			else if (e.type == SDL_MOUSEBUTTONUP)
				HandleMouseButtonUp(e);
			else if (e.type == SDL_MOUSEWHEEL)
				HandleMouseWheel(e);
			else if (e.type == SDL_TEXTINPUT)
				HandleText(e);
			else if (e.type == SDL_KEYDOWN)
				HandleKeyboard(e);
		}

		int mousex, mousey;

		SDL_GetMouseState(&mousex, &mousey);

		_mousePosition = glm::vec2(float(mousex), _windowSize.y - float(mousey));

		return result;
	}
Esempio n. 2
0
bool Widget::TriggerMouseWheel(const MouseWheelEvent &event, bool handled)
{
	HandleMouseWheel(event);
	if (!handled) handled = onMouseWheel.emit(event);
	if (GetContainer()) {
		MouseWheelEvent translatedEvent = MouseWheelEvent(event.direction, event.pos+GetPosition());
		handled = GetContainer()->TriggerMouseWheel(translatedEvent, handled);
	}
	return handled;
}
Esempio n. 3
0
bool Widget::TriggerMouseWheel(const MouseWheelEvent &event, bool emit)
{
	HandleMouseWheel(event);
	if (emit) emit = !onMouseWheel.emit(event);
	if (GetContainer()) {
		MouseWheelEvent translatedEvent = MouseWheelEvent(event.direction, event.pos+GetPosition());
		GetContainer()->TriggerMouseWheel(translatedEvent, emit);
	}
	return !emit;
}
Esempio n. 4
0
// MessageReceived -- Handle the stuff, baby. yeah.
void AllesView::MessageReceived(BMessage *e) {
   switch ( e->what ) {
      case B_KEY_UP:
             KeyUp( e->FindString("bytes"), strlen( e->FindString("bytes") ) );
             return;
      case  B_MOUSE_WHEEL_CHANGED:
            HandleMouseWheel(e->FindFloat("be:wheel_delta_y")); 
            return;
      default:  BView::MessageReceived(e); 
   }
}
Esempio n. 5
0
void SpectraDocumentFrame::OnMouseWheelEvent(wxMouseEvent& event)
{
	try
	{
		HandleMouseWheel(event);
		event.Skip();
		Update();
	}
	catch(oglplus::MissingFunction& mfe) { parent_app.HandleError(mfe, this); }
	catch(oglplus::ProgramBuildError& pbe) { parent_app.HandleError(pbe, this); }
	catch(oglplus::LimitError& le) { parent_app.HandleError(le, this); }
	catch(oglplus::Error& err) { parent_app.HandleError(err, this); }
	catch(const std::exception& se) { parent_app.HandleError(se, this); }
}