Check for right click on a derma panel

Hello everyone,

Im trying to open a small menu when i right click on a DList, However im having 2 problems.

First of all, Im trying to make the menu open using right click with this code:

	local mcode = 108
	function statsList:OnMousePressed(mcode)

		print("right click detected")
		local rightMenu = vgui.Create("DMenu")
		rightMenu:AddOption("Add points")

However it opens with any mouse click, not specifically just the right click.

Secondly i need to be able to right click a row in a DList however it doesnt open a menu if i click on a row in the dlist, just selects it. Hopefully someone can help me out!

Thanks in advance!

Because you aren’t checking mouse code - no condition.

Fixed, Thank you. Didnt realise i had to check the mouse code, Do you possibly have a solution for my other problem?

save the original OnMousePressed and call it if the button isn’t the MOUSE_RIGHT button.


Though there’s the undocumented DoRightClick (not sure if it works outside of DButton and DButton based elements, so you could test) so you can use that instead of OnMousePressed and remove the check for the mouse code.