1
0

Added the OnClosing callback to cLuaWindow API

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1534 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-05-30 20:40:43 +00:00
parent b58f0cabad
commit 2eb1240e14
9 changed files with 160 additions and 9 deletions

View File

@@ -580,8 +580,17 @@ function HandleTestWndCmd(a_Split, a_Player)
return true;
end
-- Test out the OnClosing callback's ability to refuse to close the window
local attempt = 1;
local OnClosing = function(Window, Player)
Player:SendMessage("Window closing attempt #" .. attempt);
attempt = attempt + 1;
return (attempt <= 3); -- refuse twice, then allow
end
local Window = cLuaWindow(WindowType, WindowSizeX, WindowSizeY, "TestWnd");
Window:SetSlot(a_Player, 0, cItem(E_ITEM_DIAMOND, 64));
Window:SetOnClosing(OnClosing);
a_Player:OpenWindow(Window);