Jump to content

How to detect ISContextMenu option was selected?


toastonrye

Recommended Posts

 

function ISWorldMap:onRightMouseUp(x, y)
	local playerNum = 0
	local playerObj = getSpecificPlayer(playerNum)
	if not playerObj then return end 
	local context = ISContextMenu.get(playerNum, x + self:getAbsoluteX(), y + self:getAbsoluteY())

	local worldX = self.mapAPI:uiToWorldX(x, y)
	local worldY = self.mapAPI:uiToWorldY(x, y)
	if getWorld():getMetaGrid():isValidChunk(worldX / 10, worldY / 10) then
		option = context:addOption("Teleport: " .. math.floor(worldX) .. " | " .. math.floor(worldY), self, self.onTeleport, worldX, worldY)
	end
	return true
end

 

After the above option is clicked on, I'd like to run self:close() to close the map.

 

I see in ISContextMenu.lua there is:

 

function ISContextMenu:onMouseDown(x, y)

end

 

But I can't work it out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...