Summary: Adding Mouse Wheel Event Support to RingQtApplication: A POS system written in Ring using the RingQt library (guilib). Requirement: scrolling the mouse wheel over the tab bar / sidebar switches between tabs.
Current limitation: The QAllEvents class (the event filter that intercepts Qt events and forwards them to Ring code) does not support QEvent::Wheel at all. GAllEvents::eventFilter in gallevents.cpp handles many event types (KeyPress, MouseButtonPress, Resize, etc.) but has no branch for the wheel event — it returns false and passes the event through untouched. As a result, Ring code can never capture the mouse wheel.
Requested: Add WheelEvent support to QAllEvents — an additive, non-breaking change. Exact locations (relative to the ring folder):
1) extensions\ringqt\classes\widgets\qallevents.cfAfter the setChildRemovedEvent/getChildRemovedEvent lines, add:
void setWheelEvent(const char *cStr)
int getWheelDelta(void)
int getWheelDeltaX(void)
This file is the source of truth; gencode.bat automatically generates from it both the export functions in cpp\src\ring_qt.cpp and the wrapper methods in ..\..\libraries\guilib\classes\ring_qt.ring.
2) extensions\ringqt\cpp\include\gallevents.hAdd the members (initialized in the constructor):
char cWheelEvent[RINGQT_EVENT_SIZE];
int nWheelDelta ;
int nWheelDeltaX ;
And the method declarations:
void setWheelEvent(const char *cStr);
void callWheelEvent(void);
int getWheelDelta(void);
int getWheelDeltaX(void);
3) extensions\ringqt\cpp\src\gallevents.cpp- In the constructor: strcpy(this->cWheelEvent,""); this->nWheelDelta=0; this->nWheelDeltaX=0;
- Inside eventFilter, add a branch (same pattern as the existing ones):
else if ((event->type() == QEvent::Wheel) && (strcmp(this->cWheelEvent,"")!=0) ) {
QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event);
this->nWheelDelta = wheelEvent->angleDelta().y();
this->nWheelDeltaX = wheelEvent->angleDelta().x();
this->callWheelEvent();
return this->lEventOutput;
}
- Add the functions (same pattern as the existing setKeyPressEvent/callKeyPressEvent):
void GAllEvents::setWheelEvent(const char *cStr) {
if (strlen(cStr)<100) strcpy(this->cWheelEvent,cStr);
}
void GAllEvents::callWheelEvent(void) {
if (strcmp(this->cWheelEvent,"")==0) return ;
ring_vm_runcode(this->pVM,this->cWheelEvent);
}
int GAllEvents::getWheelDelta(void) { return this->nWheelDelta ; }
int GAllEvents::getWheelDeltaX(void) { return this->nWheelDeltaX ; }
- Add #include <QWheelEvent> if not already included via ringqt.h.
4) Build stepsgencode.bat ← regenerates ring_qt.cpp + ring_qt.ring
buildvc.bat ← rebuilds the DLL (requires Qt 5.15 + MSVC/MinGW)
Intended usage in Ring code (after the build)oTabNavFilter.setWheelEvent("pTabWheel()")
Func pTabWheel
if oTabNavFilter.getWheelDelta() > 0
pGoTabRel(-1) # scroll up = previous tab
else
pGoTabRel(1) # scroll down = next tab
ok
oTabNavFilter.seteventoutput(TRUE)
Note on sign: angleDelta().y() is positive when scrolling up and negative when scrolling down.