implement triple click

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5148 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-08-29 01:25:41 +00:00
parent 5ef09542a2
commit 9f535fa42b
4 changed files with 59 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2002-08-29 John Levon <levon@movementarian.org>
* QContentPane.C:
* QContentPane.h: implement triple click
2002-08-29 John Levon <levon@movementarian.org>
* QInclude.C: remove some wrong code removed from xforms

View File

@ -20,6 +20,8 @@
#include <qevent.h>
#include <qpainter.h>
#include <qtimer.h>
#include <qapplication.h>
using std::endl;
@ -97,6 +99,15 @@ void QContentPane::scrollBarChanged(int val)
void QContentPane::mousePressEvent(QMouseEvent * e)
{
if (dc_event_.active && dc_event_ == *e) {
dc_event_.active = false;
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
wa_->dispatch(cmd);
return;
}
FuncRequest cmd
(LFUN_MOUSE_PRESS, e->x(), e->y(), q_button_state(e->button()));
wa_->dispatch(cmd);
@ -130,12 +141,27 @@ void QContentPane::keyPressEvent(QKeyEvent * e)
}
void QContentPane::doubleClickTimeout()
{
if (!dc_event_.active)
return;
dc_event_.active = false;
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
wa_->dispatch(cmd);
}
void QContentPane::mouseDoubleClickEvent(QMouseEvent * e)
{
FuncRequest cmd
(LFUN_MOUSE_DOUBLE, e->x(), e->y(), q_button_state(e->button()));
wa_->dispatch(cmd);
// FIXME: triple click
dc_event_ = double_click(e);
// doubleClickInterval() is just too long.
QTimer::singleShot(QApplication::doubleClickInterval() / 1.5,
this, SLOT(doubleClickTimeout()));
}

View File

@ -25,6 +25,26 @@
class QWorkArea;
/// for emulating triple click
struct double_click {
int x;
int y;
Qt::ButtonState state;
bool active;
bool operator==(QMouseEvent const & e) {
return x == e.x() && y == e.y()
&& state == e.button();
}
double_click()
: x(0), y(0), state(Qt::NoButton), active(false) {}
double_click(QMouseEvent * e)
: x(e->x()), y(e->y()),
state(e->button()), active(true) {}
};
/**
* Widget for actually drawing the document on
*/
@ -56,6 +76,8 @@ protected:
void keyPressEvent(QKeyEvent * e);
public slots:
void doubleClickTimeout();
void scrollBarChanged(int);
private:
@ -64,6 +86,8 @@ private:
/// the double buffered pixmap
boost::scoped_ptr<QPixmap> pixmap_;
double_click dc_event_;
};
#endif // QCONTENTPANE_H

View File

@ -23,7 +23,6 @@ QCommandBuffer
QContentPane
- triple click
- figure out why a scroll doesn't update quickly, which leaves cursor artifacts
whilst holding down page down etc.
@ -35,10 +34,6 @@ qfont_loader
- use lyxrc, check for failure, implement available()
qfont_metrics
- per char ascent/descent
QForks
- don't implement me
@ -47,10 +42,6 @@ QGraphics
- remaining UI cleanups and fixes
QInclude
- check no load stuff works ?
QLImage
- get jpeg etc. to work