Jump to content

Mouse Wheel Scrolling UI Event

Recommended Posts

M2 Download Center

Download Here ( 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.






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;



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())


Then root/ui.py and find ScrollBar class and add this function to it:


def OnMouseWheel(self, nLen):
		if nLen > 0:
			return True
		elif nLen < 0:
			return True
		return False


But you can use OnMouseWheel everywhere to listen to scrolling.


Good luck!

  • Love 13
  • Love 1

C++ programmer at Gameloft

Link to post
  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



Chatroom Rules


Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules


  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.