summaryrefslogtreecommitdiffabout
path: root/microkde/ktextedit.cpp
blob: 4dd6875f8bfd76a04a09be0e2459b7f3da20b569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#include <ktextedit.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#endif


KTextEdit::KTextEdit ( QWidget *parent ) : QMultiLineEdit( parent ) 
{
    mAllowPopupMenu = false; 
    mMouseDown = false; 
    mIgnoreMark = false; 
#ifndef DESKTOP_VERSION 
    QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
#endif 
}

void KTextEdit::mousePressEvent(QMouseEvent *e)
{
    if (  e->button() == LeftButton ) {
        mAllowPopupMenu = true;
        mYMousePos = mapToGlobal( (e->pos())).y();
        mXMousePos = mapToGlobal( (e->pos())).x();
    }
     if (  e->button() == RightButton &&  !mAllowPopupMenu   )
      return;
    if (  e->button() == LeftButton ) {
        if ( hasMarkedText () )
            mIgnoreMark = !mIgnoreMark;
        if ( mIgnoreMark && hasMarkedText () ) {
            mMouseDown = false;
            return ;
        }
    }
    QMultiLineEdit::mousePressEvent( e );
}

void KTextEdit::mouseReleaseEvent(QMouseEvent *e)
{
    QMultiLineEdit::mouseReleaseEvent(e);
}

void KTextEdit::mouseMoveEvent(QMouseEvent *e)
{
    int diff = mYMousePos - mapToGlobal( (e->pos())).y();
    if ( diff < 0 ) diff = -diff;
    int diff2 = mXMousePos - mapToGlobal( (e->pos())).x();
    if ( diff2 < 0 ) diff2 = -diff2;
    if ( diff+ diff2 > 20 )
        mAllowPopupMenu = false;
    QMultiLineEdit::mouseMoveEvent(e);
}