Exemplo n.º 1
0
void PopupWindow::makeFloating()
{
    stopFilteringMessages();
    setMoveable(true);
}
Exemplo n.º 2
0
bool PopupWindow::onProcessMessage(Message* msg)
{
    switch (msg->type()) {

    case kCloseMessage:
        stopFilteringMessages();
        break;

    case kMouseLeaveMessage:
        if (m_hotRegion.isEmpty() && !isMoveable())
            closeWindow(NULL);
        break;

    case kKeyDownMessage:
        if (m_filtering) {
            KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
            KeyScancode scancode = keymsg->scancode();

            if (scancode == kKeyEsc ||
                    scancode == kKeyEnter ||
                    scancode == kKeyEnterPad) {
                closeWindow(NULL);
            }

            // If we are filtering messages we don't propagate key-events
            // to other widgets. As we're a popup window and we're
            // filtering messages, the user shouldn't be able to start
            // other actions pressing keyboard shortcuts.
            return false;
        }
        break;

    case kMouseDownMessage:
        if (m_filtering) {
            gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();

            switch (m_clickBehavior) {

            // If the user click outside the window, we have to close
            // the tooltip window.
            case kCloseOnClickInOtherWindow: {
                Widget* picked = pick(mousePos);
                if (!picked || picked->getRoot() != this) {
                    closeWindow(NULL);
                }
                break;
            }

            case kCloseOnClickOutsideHotRegion:
                if (!m_hotRegion.contains(mousePos)) {
                    closeWindow(NULL);
                }
                break;
            }
        }
        break;

    case kMouseMoveMessage:
        if (!isMoveable() &&
                !m_hotRegion.isEmpty() &&
                getManager()->getCapture() == NULL) {
            gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();

            // If the mouse is outside the hot-region we have to close the
            // window.
            if (!m_hotRegion.contains(mousePos))
                closeWindow(NULL);
        }
        break;

    }

    return Window::onProcessMessage(msg);
}
Exemplo n.º 3
0
bool PopupWindow::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    // There are cases where startFilteringMessages() is called when a
    // kCloseMessage for this same PopupWindow is enqueued. Processing
    // the kOpenMessage we ensure that the popup will be filtering
    // messages if it's needed when it's visible (as kCloseMessage and
    // kOpenMessage must be enqueued in the correct order).
    case kOpenMessage:
      if (!isMoveable())
        startFilteringMessages();
      break;

    case kCloseMessage:
      stopFilteringMessages();
      break;

    case kMouseLeaveMessage:
      if (m_hotRegion.isEmpty() && !isMoveable())
        closeWindow(nullptr);
      break;

    case kKeyDownMessage:
      if (m_filtering) {
        KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
        KeyScancode scancode = keymsg->scancode();

        if (scancode == kKeyEsc)
          closeWindow(nullptr);

        if (m_enterBehavior == kCloseOnEnter &&
            (scancode == kKeyEnter ||
             scancode == kKeyEnterPad)) {
          closeWindow(this);
          return true;
        }
      }
      break;

    case kMouseDownMessage:
      if (m_filtering) {
        gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();

        switch (m_clickBehavior) {

          // If the user click outside the window, we have to close
          // the tooltip window.
          case kCloseOnClickInOtherWindow: {
            Widget* picked = pick(mousePos);
            if (!picked || picked->getRoot() != this) {
              closeWindow(NULL);
            }
            break;
          }

          case kCloseOnClickOutsideHotRegion:
            if (!m_hotRegion.contains(mousePos)) {
              closeWindow(NULL);
            }
            break;
        }
      }
      break;

    case kMouseMoveMessage:
      if (!isMoveable() &&
          !m_hotRegion.isEmpty() &&
          getManager()->getCapture() == NULL) {
        gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();

        // If the mouse is outside the hot-region we have to close the
        // window.
        if (!m_hotRegion.contains(mousePos))
          closeWindow(NULL);
      }
      break;

  }

  return Window::onProcessMessage(msg);
}