##// 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 136 void QChartView::mousePressEvent(QMouseEvent *event)
137 137 {
138 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
139
140 QRectF plotArea = d_ptr->m_chart->plotArea();
141
142 if (plotArea.contains(event->pos())) {
143 d_ptr->m_rubberBandOrigin = event->pos();
144 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
145 d_ptr->m_rubberBand->show();
146 event->accept();
147 }
138 QRectF plotArea = d_ptr->m_chart->plotArea();
139 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled()
140 && event->button() == Qt::LeftButton && plotArea.contains(event->pos())) {
141 d_ptr->m_rubberBandOrigin = event->pos();
142 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
143 d_ptr->m_rubberBand->show();
144 event->accept();
148 145 } else {
149 146 QGraphicsView::mousePressEvent(event);
150 147 }
@@ -181,8 +178,8 void QChartView::mouseMoveEvent(QMouseEvent *event)
181 178 */
182 179 void QChartView::mouseReleaseEvent(QMouseEvent *event)
183 180 {
184 if (d_ptr->m_rubberBand) {
185 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
181 if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
182 if (event->button() == Qt::LeftButton) {
186 183 d_ptr->m_rubberBand->hide();
187 184 QRectF rect = d_ptr->m_rubberBand->geometry();
188 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