uint32_t
nsMenuBarListener::GetModifiers(nsIDOMKeyEvent* aKeyEvent)
{
  uint32_t modifiers = 0;
  WidgetInputEvent* inputEvent =
    static_cast<WidgetInputEvent*>(aKeyEvent->GetInternalNSEvent());
  MOZ_ASSERT(inputEvent);

  if (inputEvent->IsShift()) {
    modifiers |= MODIFIER_SHIFT;
  }

  if (inputEvent->IsControl()) {
    modifiers |= MODIFIER_CONTROL;
  }

  if (inputEvent->IsAlt()) {
    modifiers |= MODIFIER_ALT;
  }

  if (inputEvent->IsMeta()) {
    modifiers |= MODIFIER_META;
  }

  if (inputEvent->IsOS()) {
    modifiers |= MODIFIER_OS;
  }

  return modifiers;
}
Пример #2
0
bool
nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
{
    WidgetInputEvent* inputEvent = mEvent->AsInputEvent();
    MOZ_ASSERT(inputEvent, "mEvent must be WidgetInputEvent or derived class");
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
        return inputEvent->IsShift();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CONTROL)) {
        return inputEvent->IsControl();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_META)) {
        return inputEvent->IsMeta();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALT)) {
        return inputEvent->IsAlt();
    }

    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALTGRAPH)) {
        return inputEvent->IsAltGraph();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_OS)) {
        return inputEvent->IsOS();
    }

    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CAPSLOCK)) {
        return inputEvent->IsCapsLocked();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_NUMLOCK)) {
        return inputEvent->IsNumLocked();
    }

    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_FN)) {
        return inputEvent->IsFn();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SCROLLLOCK)) {
        return inputEvent->IsScrollLocked();
    }
    if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SYMBOLLOCK)) {
        return inputEvent->IsSymbolLocked();
    }
    return false;
}
Пример #3
0
bool
nsXBLPrototypeHandler::ModifiersMatchMask(
                         nsIDOMUIEvent* aEvent,
                         const IgnoreModifierState& aIgnoreModifierState)
{
  WidgetInputEvent* inputEvent = aEvent->AsEvent()->WidgetEventPtr()->AsInputEvent();
  NS_ENSURE_TRUE(inputEvent, false);

  if (mKeyMask & cMetaMask) {
    if (inputEvent->IsMeta() != ((mKeyMask & cMeta) != 0)) {
      return false;
    }
  }

  if ((mKeyMask & cOSMask) && !aIgnoreModifierState.mOS) {
    if (inputEvent->IsOS() != ((mKeyMask & cOS) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cShiftMask && !aIgnoreModifierState.mShift) {
    if (inputEvent->IsShift() != ((mKeyMask & cShift) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cAltMask) {
    if (inputEvent->IsAlt() != ((mKeyMask & cAlt) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cControlMask) {
    if (inputEvent->IsControl() != ((mKeyMask & cControl) != 0)) {
      return false;
    }
  }

  return true;
}
bool
nsXBLPrototypeHandler::ModifiersMatchMask(nsIDOMUIEvent* aEvent,
                                          bool aIgnoreShiftKey)
{
  WidgetInputEvent* inputEvent = aEvent->GetInternalNSEvent()->AsInputEvent();
  NS_ENSURE_TRUE(inputEvent, false);

  if (mKeyMask & cMetaMask) {
    if (inputEvent->IsMeta() != ((mKeyMask & cMeta) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cOSMask) {
    if (inputEvent->IsOS() != ((mKeyMask & cOS) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cShiftMask && !aIgnoreShiftKey) {
    if (inputEvent->IsShift() != ((mKeyMask & cShift) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cAltMask) {
    if (inputEvent->IsAlt() != ((mKeyMask & cAlt) != 0)) {
      return false;
    }
  }

  if (mKeyMask & cControlMask) {
    if (inputEvent->IsControl() != ((mKeyMask & cControl) != 0)) {
      return false;
    }
  }

  return true;
}