Example #1
0
/*!
  This function is not intended as polymorphic usage. Just a shared code
  fragment that calls QInputContext::mouseHandler for this
  class.
*/
bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
{
#if !defined QT_NO_IM
    Q_Q(QLineEdit);
    if ( control->composeMode() ) {
	int tmp_cursor = xToPos(e->pos().x());
	int mousePos = tmp_cursor - control->cursor();
	if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) {
            mousePos = -1;
	    // don't send move events outside the preedit area
            if ( e->type() == QEvent::MouseMove )
                return true;
        }

        QInputContext *qic = q->inputContext();
        if ( qic )
            // may be causing reset() in some input methods
            qic->mouseHandler(mousePos, e);
        if (!control->preeditAreaText().isEmpty())
            return true;
    }
#else
    Q_UNUSED(e);
#endif

    return false;
}
Example #2
0
void MDeclarativeScreen::sendClicked(int x, int y, int position) const
{
    QInputContext *ic = qApp->inputContext();

    if (ic != NULL) {
        QEvent::Type mouseEventType(QEvent::MouseButtonRelease);
        QPoint mousePoint(x,y);
        QMouseEvent mouseEvent(mouseEventType, mousePoint, Qt::LeftButton,
                               Qt::LeftButton, Qt::NoModifier);
        int preeditOffset = 0;
        ic->mouseHandler(preeditOffset, &mouseEvent);
    }
}