Пример #1
0
bool SkOSWindow::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    switch (message) {
        case WM_KEYDOWN: {
            SkKey key = winToskKey(wParam);
            if (kNONE_SkKey != key) {
                this->handleKey(key);
                return true;
            }
        } break;
        case WM_KEYUP: {
            SkKey key = winToskKey(wParam);
            if (kNONE_SkKey != key) {
                this->handleKeyUp(key);
                return true;
            }
        } break;
        case WM_UNICHAR:
            this->handleChar((SkUnichar) wParam);
            return true;
        case WM_CHAR: {
            this->handleChar(SkUTF8_ToUnichar((char*)&wParam));
            return true;
        } break;
        case WM_SIZE: {
            INT width = LOWORD(lParam);
            INT height = HIWORD(lParam);
            this->resize(width, height);
            break;
        }
        case WM_PAINT: {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            this->doPaint(hdc);
            EndPaint(hWnd, &ps);
            return true;
            } break;

        case WM_LBUTTONDOWN:
            this->handleClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                              Click::kDown_State, NULL, getModifiers(message));
            return true;

        case WM_MOUSEMOVE:
            this->handleClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                              Click::kMoved_State, NULL, getModifiers(message));
            return true;

        case WM_LBUTTONUP:
            this->handleClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                              Click::kUp_State, NULL, getModifiers(message));
            return true;

        case WM_EVENT_CALLBACK:
            if (SkEvent::ProcessEvent()) {
                post_skwinevent();
            }
            return true;
    }
    return false;
}
Пример #2
0
	void mouse(int button, int state, int x, int y)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			if (state == GLUT_DOWN) {
				window->mousePressed(MouseEvent(getModifiers(), getButton(button), Point(x, y)));
			} else if (state == GLUT_UP) {
				window->mouseReleased(MouseEvent(getModifiers(), getButton(button), Point(x, y)));
			}
		}
	}
Пример #3
0
bool ImageKnob::onMotion(int x, int y)
{
    if (! fDragging)
        return false;

    bool doVal = false;
    float d, value;

    if (fOrientation == ImageKnob::Horizontal)
    {
        if (int movX = x - fLastX)
        {
            d     = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
            value = fValueTmp + (float(fMaximum - fMinimum) / d * float(movX));
            doVal = true;
        }
    }
    else if (fOrientation == ImageKnob::Vertical)
    {
        if (int movY = fLastY - y)
        {
            d     = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
            value = fValueTmp + (float(fMaximum - fMinimum) / d * float(movY));
            doVal = true;
        }
    }

    if (! doVal)
        return false;

    if (value < fMinimum)
    {
        value = fMinimum;
        fValueTmp = value;
    }
    else if (value > fMaximum)
    {
        value = fMaximum;
        fValueTmp = value;
    }
    else if (fStep != 0.0f)
    {
        fValueTmp = value;
        const float rest = std::fmod(value, fStep);
        value = value - rest + (rest > fStep/2.0f ? fStep : 0.0f);
    }

    setValue(value, true);

    fLastX = x;
    fLastY = y;

    return true;
}
Пример #4
0
void LLKeyboardMacOSX::resetMaskKeys()
{
	U32 mask = getModifiers();

	// MBW -- XXX -- This mirrors the operation of the Windows version of resetMaskKeys().
	//    It looks a bit suspicious, as it won't correct for keys that have been released.
	//    Is this the way it's supposed to work?
	
	// We apply the modifier masks directly within getModifiers.  So check to see which masks we've applied.

	if(mask & MAC_SHIFT_KEY)
	{
		mKeyLevel[KEY_SHIFT] = TRUE;
	}

	if(mask & MAC_CTRL_KEY)
	{
		mKeyLevel[KEY_CONTROL] = TRUE;
	}

	if(mask & MAC_ALT_KEY)
	{
		mKeyLevel[KEY_ALT] = TRUE;
	}
}
Пример #5
0
void ShortcutLineEdit::keyPressEvent(QKeyEvent *e)
{
	int nextKey = e->key();
	if ( keys.count() > 3 || // too long shortcut
	     nextKey == Qt::Key_Control || // dont count modifier keys
	     nextKey == Qt::Key_Shift ||
	     nextKey == Qt::Key_Meta ||
	     nextKey == Qt::Key_Alt )
		return;
	
	// applying current modifiers to key
	nextKey |= getModifiers(e->modifiers(), e->text());
	
	// If there is selected text, replace *all* instead of appending. 
	if (hasSelectedText())
	{
		keys.clear();
	}
	keys.append(nextKey);
	
	// set displaying information
	setText(getKeySequence().toString(QKeySequence::NativeText));
	emit contentsChanged();
	
	// not call QLineEdit's event because we already changed contents
	e->accept();
}
static void
MenuItem_selected(Widget w, XtPointer client_data, XmAnyCallbackStruct * s)
{
	extern int      getModifiers(int state);
	jint            modifiers = (jint) getModifiers(s->event->xbutton.state);
	jlong           when = (jlong) s->event->xbutton.time;
	JNIEnv         *env;
	jobject         this = (jobject) client_data;

	if ((*JVM)->AttachCurrentThread(JVM, (void **) &env, NULL) != 0)
		return;

	if ((*env)->GetBooleanField(env, this, MCachedIDs.MMenuItemPeer_isCheckboxFID) == JNI_TRUE) {
		Boolean         state;
		struct MenuItemData *mdata =

		(struct MenuItemData *) (*env)->GetIntField(env, this, MCachedIDs.MMenuItemPeer_pDataFID);

		if (mdata != NULL) {
			XtVaGetValues(mdata->comp.widget, XmNset, &state, NULL);

			(*env)->CallVoidMethod(env, this, MCachedIDs.MCheckboxMenuItemPeer_actionMID, when,
				   modifiers, state ? JNI_TRUE : JNI_FALSE);
		}
	} else
		(*env)->CallVoidMethod(env, this, MCachedIDs.MMenuItemPeer_actionMID, when, modifiers);

	if ((*env)->ExceptionCheck(env))
		(*env)->ExceptionDescribe(env);
}
Пример #7
0
void cv::viz::InteractorStyle::OnMouseWheelBackward()
{
    Vec2i p(Interactor->GetEventPosition());
    MouseEvent event(MouseEvent::MouseScrollDown, MouseEvent::VScroll, p, getModifiers());
    if (mouseCallback_)
        mouseCallback_(event, mouse_callback_cookie_);

    if (Interactor->GetRepeatCount() && mouseCallback_)
        mouseCallback_(event, mouse_callback_cookie_);

    if (Interactor->GetAltKey())
    {
        // zoom
        vtkSmartPointer<vtkCamera> cam = CurrentRenderer->GetActiveCamera();
        double opening_angle = cam->GetViewAngle();
        if (opening_angle < 170.0)
            opening_angle += 1.0;

        cam->SetViewAngle(opening_angle);
        cam->Modified();
        CurrentRenderer->ResetCameraClippingRange();
        CurrentRenderer->Modified();
        CurrentRenderer->Render();
        Interactor->Render();
    }
    else
        Superclass::OnMouseWheelBackward();
}
Пример #8
0
	void keyboardUp(unsigned char key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), GLUT_TO_KEYEVENT_KEYS[key]));
		}
	}
Пример #9
0
	void specialUp(int key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), getSpecialKey(key)));
		}
	}
Пример #10
0
KeyMonitor::KeyMonitor(QObject* parent)
: QObject(parent),
  m_modifiers(Qt::NoModifier)
{
    if (registerEvents()) {
        getModifiers();
    }
}
Пример #11
0
		void mouseButton( int button, int state, int x, int y )
		{
			// Texture has been scaled so it's 1:1 with screen pixels, so no need to scale mouse coords here.
//			x = ( x * mAppTextureWidth ) / mAppWindowWidth;
//			y = ( y * mAppTextureHeight ) / mAppWindowHeight;

			if ( button == GLUT_LEFT_BUTTON )
			{
				if ( state == GLUT_DOWN )
					mMediaSource->mouseEvent(LLPluginClassMedia::MOUSE_EVENT_DOWN, x, y, getModifiers());
				else if ( state == GLUT_UP )
					mMediaSource->mouseEvent(LLPluginClassMedia::MOUSE_EVENT_UP, x, y, getModifiers());
			}

			// force a GLUT update
			glutPostRedisplay();
		};
Пример #12
0
void cv::viz::InteractorStyle::OnRightButtonUp()
{
    Vec2i p(Interactor->GetEventPosition());
    MouseEvent event(MouseEvent::MouseButtonRelease, MouseEvent::RightButton, p, getModifiers());
    if (mouseCallback_)
        mouseCallback_(event, mouse_callback_cookie_);
    Superclass::OnRightButtonUp();
}
Пример #13
0
KeyMonitor::KeyMonitor(QObject* parent)
: QObject(parent), m_stop(false)
{
    if (this->registerEvents()) {
        getModifiers();
        m_future = QtConcurrent::run(this, &KeyMonitor::run);
    }
}
Пример #14
0
string Item::getShortName(const Creature* owner, bool plural) const {
  PROFILE;
  if (owner && owner->isAffected(LastingEffect::BLIND) && attributes->blindName)
    return getBlindName(plural);
  if (attributes->artifactName)
    return *attributes->artifactName + " " + getModifiers(true);
  string name;
  if (!attributes->prefixes.empty())
    name = attributes->prefixes.back();
  else if (attributes->shortName) {
    name = *attributes->shortName;
    appendWithSpace(name, getSuffix());
  } else
    name = getVisibleName(plural);
  appendWithSpace(name, getModifiers(true));
  return name;
}
Пример #15
0
bool ShortcutDialog::eventFilter(QObject *object, QEvent *event)
{
    if (object != ui->lineEditShortcut)
        return false;

    if (event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
        COPYQ_LOG(QString("Shortcut key press: %1").arg(keyEvent->key()));

        const int key = createPlatformNativeInterface()->keyCode(*keyEvent);
        Qt::KeyboardModifiers mods = getModifiers(*keyEvent);

        if (mods == Qt::NoModifier) {
            if (key == Qt::Key_Tab)
                return false;

            if (key == Qt::Key_Escape) {
                reject();
                return true;
            }

            if (m_expectModifier)
                return true;
        }

        event->accept();
        processKey(key, mods);

        if ( isNonModifierKey(key) )
            accept();

        return false;
    } else if (event->type() == QEvent::KeyRelease) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
        COPYQ_LOG(QString("Shortcut key release: %1").arg(keyEvent->key()));

        Qt::KeyboardModifiers mods = getModifiers(*keyEvent);

        processKey(0, mods);

        return true;
    }

    return false;
}
Пример #16
0
bool ImageKnob::onMotion(int x, int y)
{
    if (! fDragging)
        return false;

    if (fOrientation == ImageKnob::Horizontal)
    {
        int movX = x - fLastX;

        if (movX != 0)
        {
            float d     = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
            float value = fValue + (float(fMaximum - fMinimum) / d * float(movX));

            if (value < fMinimum)
                value = fMinimum;
            else if (value > fMaximum)
                value = fMaximum;

            setValue(value, true);
        }
    }
    else if (fOrientation == ImageKnob::Vertical)
    {
        int movY = fLastY - y;

        if (movY != 0)
        {
            float d     = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f;
            float value = fValue + (float(fMaximum - fMinimum) / d * float(movY));

            if (value < fMinimum)
                value = fMinimum;
            else if (value > fMaximum)
                value = fMaximum;

            setValue(value, true);
        }
    }

    fLastX = x;
    fLastY = y;

    return true;
}
Пример #17
0
void cv::viz::InteractorStyle::OnRightButtonDown()
{
    Vec2i p(Interactor->GetEventPosition());
    MouseEvent::Type type = (Interactor->GetRepeatCount() == 0) ? MouseEvent::MouseButtonPress : MouseEvent::MouseDblClick;
    MouseEvent event(type, MouseEvent::RightButton, p, getModifiers());
    if (mouseCallback_)
        mouseCallback_(event, mouse_callback_cookie_);
    Superclass::OnRightButtonDown();
}
Пример #18
0
static bool modifier_held(int modifier) {
    rogueEvent tempEvent;

    getModifiers(&tempEvent);
    if (modifier == 0) return tempEvent.shiftKey;
    if (modifier == 1) return tempEvent.controlKey;

    return 0;
}
Пример #19
0
void EventSenderProxy::setTouchModifier(WKEventModifiers modifier, bool enable)
{
    Qt::KeyboardModifiers mod = getModifiers(modifier);

    if (enable)
        m_touchModifiers |= mod;
    else
        m_touchModifiers &= ~mod;
}
Пример #20
0
void ZMouseEvent::print() const
{
  std::cout << "Mouse event: ";
  if (getButtons() & Qt::LeftButton) {
    std::cout << "Left button; ";
  }
  if (getButtons() & Qt::RightButton) {
    std::cout << "Right button; ";
  }
  if (getButtons() & Qt::MidButton) {
    std::cout << "Middle button; ";
  }

  switch (getAction()) {
  case ACTION_DOUBLE_CLICK:
    std::cout << "Double click; ";
    break;
  case ACTION_MOVE:
    std::cout << "Move; ";
    break;
  case ACTION_PRESS:
    std::cout << "Press; ";
    break;
  case ACTION_RELEASE:
    std::cout << "Release; ";
    break;
  default:
    break;
  }

  if (getModifiers() & Qt::ShiftModifier) {
    std::cout << "Shift; ";
  }
  if (getModifiers() & Qt::ControlModifier) {
    std::cout << "Control; ";
  }
  if (getModifiers() & Qt::AltModifier) {
    std::cout << "Alt; ";
  }

  std::cout << std::endl;
}
Пример #21
0
string Item::getShortName(bool blind, bool noSuffix) const {
  if (blind && attributes->blindName)
    return getBlindName(false);
  string name = getModifiers(true);
  if (attributes->shortName)
    name = *attributes->shortName + " " + name;
  if (getShopkeeper() && !noSuffix)
    name = name + " (unpaid)";
  if (fire->isBurning() && !noSuffix)
    name.append(" (burning)");
  return name;
}
Пример #22
0
void
awt_util_convertEventTimeAndModifiers(XEvent *event,
                                      ConvertEventTimeAndModifiers *output) {
    switch (event->type) {
    case KeyPress:
    case KeyRelease:
        output->when = awt_util_nowMillisUTC_offset(event->xkey.time);
        output->modifiers = getModifiers(event->xkey.state, 0, 0);
        break;
    case ButtonPress:
    case ButtonRelease:
        output->when = awt_util_nowMillisUTC_offset(event->xbutton.time);
        output->modifiers = getModifiers(event->xbutton.state,
            getButton(event->xbutton.button), 0);
        break;
    default:
        output->when = awt_util_nowMillisUTC();
        output->modifiers =0;
        break;
    }
}
Пример #23
0
void EventSender::mouseDown(int button, const QStringList& modifiers)
{
    Qt::KeyboardModifiers modifs = getModifiers(modifiers);
    Qt::MouseButton mouseButton;
    switch (button) {
    case 0:
        mouseButton = Qt::LeftButton;
        break;
    case 1:
        mouseButton = Qt::MidButton;
        break;
    case 2:
        mouseButton = Qt::RightButton;
        break;
    case 3:
        // fast/events/mouse-click-events expects the 4th button to be treated as the middle button
        mouseButton = Qt::MidButton;
        break;
    default:
        mouseButton = Qt::LeftButton;
        break;
    }

    // only consider a click to count, an event originated by the
    // same previous button and at the same position.
    if (m_currentButton == button
        && m_mousePos == m_clickPos
        && m_clickTimer.isActive())
        m_clickCount++;
    else
        m_clickCount = 1;

    m_currentButton = button;
    m_clickPos = m_mousePos;
    m_mouseButtons |= mouseButton;

//     qDebug() << "EventSender::mouseDown" << frame;
    QEvent* event;
    if (isGraphicsBased()) {
        event = createGraphicsSceneMouseEvent((m_clickCount == 2) ?
                    QEvent::GraphicsSceneMouseDoubleClick : QEvent::GraphicsSceneMousePress,
                    m_mousePos, m_mousePos, mouseButton, m_mouseButtons, modifs);
    } else {
        event = new QMouseEvent((m_clickCount == 2) ? QEvent::MouseButtonDblClick :
                    QEvent::MouseButtonPress, m_mousePos, m_mousePos,
                    mouseButton, m_mouseButtons, modifs);
    }

    sendOrQueueEvent(event);

    m_clickTimer.start(QApplication::doubleClickInterval(), this);
}
Пример #24
0
void GfxGLWindowGLUT::keyboardCB( unsigned char key, int x, int y )
{
    GfxGLWindowGLUT& window = getWindow();

    KeyID keyId = translateKey( key );
    ModBitfield mods = getModifiers();

    // FIXME: what does GLUT's key CB correspond to? keydown, or 
    // key press?
    //window.keyDownReceived( keyId, mods );
    window.keyPressed( keyId, mods );
    window.handleMiscEvents();
}
Пример #25
0
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers)
{
    Qt::KeyboardModifiers modifiers = getModifiers(wkModifiers);
    Qt::MouseButton mouseButton = getMouseButton(button);

    updateClickCountForButton(button);

    m_mouseButtons |= mouseButton;

    QPoint mousePos(m_position.x, m_position.y);
    QMouseEvent* event = new QMouseEvent((m_clickCount == 2) ? QEvent::MouseButtonDblClick : QEvent::MouseButtonPress,
        mousePos, mousePos, mouseButton, m_mouseButtons, modifiers);

    sendOrQueueEvent(event);
}
Пример #26
0
 void operator()(SDL_Event& event) {
   switch (event.type) {
   case SDL_KEYDOWN: {
     SDLKey key = event.key.keysym.sym;
     if (isModKey(key)) return;
     handler.handleEvent(getModifiers(SDL_GetModState()) +
                         SDL_GetKeyName(key)); }
     break;
   case SDL_MOUSEBUTTONDOWN:
     if (event.button.button == SDL_BUTTON_LEFT)
       handler.handleEvent("leftmousebutton");
     break;
   case SDL_MOUSEMOTION: {
       ostringstream o;
       o << "mouse " << event.motion.x << " " << event.motion.y;
       handler.handleEvent(o.str()); }}}
Пример #27
0
void KeyMonitor::run()
{
    XEvent event;

    while(!m_stop && !XNextEvent(m_display, &event)) {
        if (event.type == key_press_type) {
            XDeviceKeyEvent *keyEvent = (XDeviceKeyEvent *) &event;
            if (!m_modList.contains((KeyCode) keyEvent->keycode)) {
                // if not a modifier
                Q_EMIT keyPressed();
            }
        }
        else if (event.type == notify_type) {
            getModifiers();
        }
    }
}
Пример #28
0
MASK LLKeyboardMacOSX::currentMask(BOOL for_mouse_event)
{
	MASK result = MASK_NONE;
	U32 mask = getModifiers();

	if (mask & MAC_SHIFT_KEY)			result |= MASK_SHIFT;
	if (mask & MAC_CTRL_KEY)			result |= MASK_CONTROL;
	if (mask & MAC_ALT_KEY)				result |= MASK_ALT;

	// For keyboard events, consider Command equivalent to Control
	if (!for_mouse_event)
	{
		if (mask & MAC_CMD_KEY) result |= MASK_CONTROL;
	}
	
	return result;
}
Пример #29
0
Variant MethodStatement::invokeInstance(CObjRef obj, CArrRef params,
  const MethodStatementWrapper *msw, bool check /* = true */) const {
  ASSERT(msw->m_methodStatement == this);
  if (getModifiers() & ClassStatement::Static) {
    return invokeStatic(obj->o_getClassName(), params, msw, check);
  }
  if (check) attemptAccess(FrameInjection::GetClassName(false), msw);
  // The debug frame should have been pushed at ObjectMethodExpression
  DECLARE_THREAD_INFO_NOINIT
  MethScopeVariableEnvironment env(this);
  env.setCurrentObject(obj);
  env.setCurrentAlias(get_current_alias());
  EvalFrameInjection fi(msw->m_className, m_fullName->data(), env,
                        loc()->file, obj.get(), FrameInjection::ObjectMethod);
  if (m_ref) {
    return strongBind(invokeImpl(env, params));
  }
  return invokeImpl(env, params);
}
Пример #30
0
bool ShortcutDialog::eventFilter(QObject *object, QEvent *event)
{
    if (object != ui->lineEditShortcut)
        return QDialog::eventFilter(object, event);

    if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
        auto keyEvent = static_cast<QKeyEvent*>(event);
        const int key = createPlatformNativeInterface()->keyCode(*keyEvent);
        const int mods = getModifiers(*keyEvent);

        if (mods == Qt::NoModifier) {
            if (key == Qt::Key_Tab)
                return QDialog::eventFilter(object, event);

            if (key == Qt::Key_Escape) {
                reject();
                return true;
            }
        }

        event->accept();

        if (event->type() == QEvent::KeyPress) {
            COPYQ_LOG(QString("Shortcut key press: %1").arg(keyEvent->key()));

            if ( isModifierKey(keyEvent->key()) ) {
                processKey(0, mods);
            } else {
                processKey(key, mods);
                accept();
            }
        } else if (result() != QDialog::Accepted) {
            COPYQ_LOG(QString("Shortcut key release: %1").arg(keyEvent->key()));
            processKey(0, mods);
        }

        return true;
    }

    return QDialog::eventFilter(object, event);
}