Jump to content

Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( 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!

  • Metin2 Dev 152
  • kekw 1
  • Eyes 1
  • Angry 1
  • Good 34
  • Love 7
  • Love 113

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

Link to comment
https://metin2.dev/topic/24505-mouse-wheel-scrolling-ui-event/
Share on other sites

  • 4 months later...
  • 2 years later...
  • 1 year later...

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.