author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (side-by-side diff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/ktextedit.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | microkde/ktextedit.cpp | 53 |
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 @@ + +#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); +} + |