summaryrefslogtreecommitdiffabout
path: root/microkde/ktextedit.cpp
Unidiff
Diffstat (limited to 'microkde/ktextedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/ktextedit.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/microkde/ktextedit.cpp b/microkde/ktextedit.cpp
new file mode 100644
index 0000000..4dd6875
--- a/dev/null
+++ b/microkde/ktextedit.cpp
@@ -0,0 +1,53 @@
1
2#include <ktextedit.h>
3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h>
5#endif
6
7
8KTextEdit::KTextEdit ( QWidget *parent ) : QMultiLineEdit( parent )
9{
10 mAllowPopupMenu = false;
11 mMouseDown = false;
12 mIgnoreMark = false;
13#ifndef DESKTOP_VERSION
14 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
15#endif
16}
17
18void KTextEdit::mousePressEvent(QMouseEvent *e)
19{
20 if ( e->button() == LeftButton ) {
21 mAllowPopupMenu = true;
22 mYMousePos = mapToGlobal( (e->pos())).y();
23 mXMousePos = mapToGlobal( (e->pos())).x();
24 }
25 if ( e->button() == RightButton && !mAllowPopupMenu )
26 return;
27 if ( e->button() == LeftButton ) {
28 if ( hasMarkedText () )
29 mIgnoreMark = !mIgnoreMark;
30 if ( mIgnoreMark && hasMarkedText () ) {
31 mMouseDown = false;
32 return ;
33 }
34 }
35 QMultiLineEdit::mousePressEvent( e );
36}
37
38void KTextEdit::mouseReleaseEvent(QMouseEvent *e)
39{
40 QMultiLineEdit::mouseReleaseEvent(e);
41}
42
43void KTextEdit::mouseMoveEvent(QMouseEvent *e)
44{
45 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
46 if ( diff < 0 ) diff = -diff;
47 int diff2 = mXMousePos - mapToGlobal( (e->pos())).x();
48 if ( diff2 < 0 ) diff2 = -diff2;
49 if ( diff+ diff2 > 20 )
50 mAllowPopupMenu = false;
51 QMultiLineEdit::mouseMoveEvent(e);
52}
53