ContextMenu = {}
ContextMenu_mt = { __index = ContextMenu }

function ContextMenu.Create()
	local contextMenu = {}
	setmetatable(contextMenu, ContextMenu_mt)

	contextMenu.menu = intruder.GContextMenu()
	contextMenu.itemCount = 0
	contextMenu.items= {}

	return contextMenu
end

function ContextMenu:SelectAt(pos, data)
	local result = self.menu:SelectAt(pos)

	if result ~= -1 then
		self.items[result].lambda(data)
	end
end

function ContextMenu:AddItem(name, lambda)
	self.items[self.itemCount] = {["name"]=name, ["lambda"]=lambda}
	self.itemCount = self.itemCount  + 1

	self.menu:AddItem(name)
end
