CircuitView. Scroll instead of scale in case of Keyboard modifier (Ctrl/Shift) is used.
![ru5t](https://simulide.com/p/storage/ultimatemember/58/profile_photo-80x80.png?1722063849)
Quote from ru5t on June 5, 2024, 5:56 pmHi all!
I've used SketchUp web for some time and really like it's scrolling approach - moving two fingers on a trackpad while Shift is pressed leads to horizontal / vertical scroll. Depending of the movement direction.
I tried to somewhat recreate this for Circuit view. In a much simplier way - no movement direction detection . Just a wheel event + Ctrl/Shift modifier for vertical / horizontal scroll. And failed). I mean it was a quick attemtpt. I don't have QT development environment set up - no QT creator or any other QT-specific tool and sadly no QT skills. I'm just using a latest dev build.
I wanted to give it a quick try using google and common sense) no luck.void CircuitView::wheelEvent( QWheelEvent* event ) { // add scroll instead of scale when Cth or Shift is pressed during wheel event bool noModifier = event->modifiers() == Qt::KeyboardModifier::NoModifier; if (m_showScroll && !noModifier){ if (event->modifiers() == Qt::KeyboardModifier::ControlModifier){ self()->horizontalScrollBar()->wheelEvent(event); return; } if (event->modifiers() == Qt::KeyboardModifier::ShiftModifier){ self()->verticalScrollBar()->wheelEvent(event); return; } } qreal scaleFactor = pow( 2.0, event->delta() / 700.0); scale( scaleFactor, scaleFactor ); m_scale *= scaleFactor; }
But, it seems that's not how it should be done. Build results with
error: ‘virtual void QScrollBar::wheelEvent(QWheelEvent*)’ is protected within this context
So, here are the questions:
1 - is it really a quick stuff to implement?
2 - is the point of modifications selected correctly?
3 - is the selected approach overall right?
Hi all!
I've used SketchUp web for some time and really like it's scrolling approach - moving two fingers on a trackpad while Shift is pressed leads to horizontal / vertical scroll. Depending of the movement direction.
I tried to somewhat recreate this for Circuit view. In a much simplier way - no movement direction detection . Just a wheel event + Ctrl/Shift modifier for vertical / horizontal scroll. And failed). I mean it was a quick attemtpt. I don't have QT development environment set up - no QT creator or any other QT-specific tool and sadly no QT skills. I'm just using a latest dev build.
I wanted to give it a quick try using google and common sense) no luck.
void CircuitView::wheelEvent( QWheelEvent* event )
{
// add scroll instead of scale when Cth or Shift is pressed during wheel event
bool noModifier = event->modifiers() == Qt::KeyboardModifier::NoModifier;
if (m_showScroll && !noModifier){
if (event->modifiers() == Qt::KeyboardModifier::ControlModifier){
self()->horizontalScrollBar()->wheelEvent(event);
return;
}
if (event->modifiers() == Qt::KeyboardModifier::ShiftModifier){
self()->verticalScrollBar()->wheelEvent(event);
return;
}
}
qreal scaleFactor = pow( 2.0, event->delta() / 700.0);
scale( scaleFactor, scaleFactor );
m_scale *= scaleFactor;
}
But, it seems that's not how it should be done. Build results with
error: ‘virtual void QScrollBar::wheelEvent(QWheelEvent*)’ is protected within this context
So, here are the questions:
1 - is it really a quick stuff to implement?
2 - is the point of modifications selected correctly?
3 - is the selected approach overall right?
![arcachofo](https://simulide.com/p/storage/ultimatemember/2/profile_photo-80x80.png?1722063849)
Quote from arcachofo on June 7, 2024, 12:18 pmHi.
You can pan the circuit using the middle button.
Some trackpads in laptops have an actual middle button, if not it can be emulated I think.About your questions:
1 - Not sure, maybe you can use a similar approach to the middle button implementation.
2 - Yes, I think 2 finger events in trackpads are delivered to CircuitView::wheelEvent, but maybe not in all systems.
3 - As you can see QScrollBar::wheelEvent(QWheelEvent*) is protected. Maybe you can use QScrollBar::setValue(int)
Hi.
You can pan the circuit using the middle button.
Some trackpads in laptops have an actual middle button, if not it can be emulated I think.
About your questions:
1 - Not sure, maybe you can use a similar approach to the middle button implementation.
2 - Yes, I think 2 finger events in trackpads are delivered to CircuitView::wheelEvent, but maybe not in all systems.
3 - As you can see QScrollBar::wheelEvent(QWheelEvent*) is protected. Maybe you can use QScrollBar::setValue(int)