##// END OF EJS Templates
Fix mouse event handling with RubberBand...
Titta Heikkala -
r2609:cff0f629c1c4
parent child
Show More
@@ -135,16 +135,13 QChartView::RubberBands QChartView::rubberBand() const
135 */
135 */
136 void QChartView::mousePressEvent(QMouseEvent *event)
136 void QChartView::mousePressEvent(QMouseEvent *event)
137 {
137 {
138 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
138 QRectF plotArea = d_ptr->m_chart->plotArea();
139
139 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled()
140 QRectF plotArea = d_ptr->m_chart->plotArea();
140 && event->button() == Qt::LeftButton && plotArea.contains(event->pos())) {
141
141 d_ptr->m_rubberBandOrigin = event->pos();
142 if (plotArea.contains(event->pos())) {
142 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
143 d_ptr->m_rubberBandOrigin = event->pos();
143 d_ptr->m_rubberBand->show();
144 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
144 event->accept();
145 d_ptr->m_rubberBand->show();
146 event->accept();
147 }
148 } else {
145 } else {
149 QGraphicsView::mousePressEvent(event);
146 QGraphicsView::mousePressEvent(event);
150 }
147 }
@@ -181,8 +178,8 void QChartView::mouseMoveEvent(QMouseEvent *event)
181 */
178 */
182 void QChartView::mouseReleaseEvent(QMouseEvent *event)
179 void QChartView::mouseReleaseEvent(QMouseEvent *event)
183 {
180 {
184 if (d_ptr->m_rubberBand) {
181 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
185 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
182 if (event->button() == Qt::LeftButton) {
186 d_ptr->m_rubberBand->hide();
183 d_ptr->m_rubberBand->hide();
187 QRectF rect = d_ptr->m_rubberBand->geometry();
184 QRectF rect = d_ptr->m_rubberBand->geometry();
188 // Since plotArea uses QRectF and rubberband uses QRect, we can't just blindly use
185 // Since plotArea uses QRectF and rubberband uses QRect, we can't just blindly use
General Comments 0
You need to be logged in to leave comments. Login now