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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user