Honorable Member Distraught 6464 Posted August 15, 2020 Honorable Member Share Posted August 15, 2020 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Hey guys, I needed to be able to scroll on the ui with the mouse wheel and I thought it will be useful for others too so here's what to do. EterPythonLib PythonWindow.h Add virtual BOOL OnMouseWheel(int nLen); after like virtual BOOL OnMouseMiddleButtonUp(); In PythonWindow.cpp add the following function: BOOL CWindow::OnMouseWheel(int nLen) { long lValue; return PyCallClassMemberFunc(m_poHandler, "OnMouseWheel", Py_BuildValue("(i)", nLen), &lValue) && 0 != lValue; } In PythonWindowManager.h add bool RunMouseWheel(int nLen); after like void RunMouseMiddleButtonUp(long x, long y); In PythonWindowManager.cpp add the definition somewhere: bool CWindowManager::RunMouseWheel(int nLen) { CWindow* pWin = GetPointWindow(); while (pWin) { if (pWin->OnMouseWheel(nLen)) return true; pWin = pWin->GetParent(); } return false; } UserInterface In PythonApplicationEvent.cpp override the following function: void CPythonApplication::OnMouseWheel(int nLen) { UI::CWindowManager& rkWndMgr = UI::CWindowManager::Instance(); if (!rkWndMgr.RunMouseWheel(nLen)) { CCameraManager& rkCmrMgr = CCameraManager::Instance(); if (CCamera* pkCmrCur = rkCmrMgr.GetCurrentCamera()) pkCmrCur->Wheel(nLen); } } Then root/ui.py and find ScrollBar class and add this function to it: def OnMouseWheel(self, nLen): if nLen > 0: self.OnUp() return True elif nLen < 0: self.OnDown() return True return False But you can use OnMouseWheel everywhere to listen to scrolling. Good luck! 115 1 1 1 28 5 91 Link to comment Share on other sites More sharing options...
Finnael 531 Posted August 15, 2020 Share Posted August 15, 2020 Thanks, pretty useful stuff. Link to comment Share on other sites More sharing options...
Morpheus™ 51 Posted December 28, 2020 Share Posted December 28, 2020 Thank you! + Link to comment Share on other sites More sharing options...
mrblue2 0 Posted February 12, 2023 Share Posted February 12, 2023 Thanks, pretty useful stuff. Link to comment Share on other sites More sharing options...
Premium KolenMG 122 Posted September 12 Premium Share Posted September 12 Works Perfectly. Thank you!! Link to comment Share on other sites More sharing options...
Recommended Posts