From 2eb1240e14986e1cccc02a96713133a003347f8b Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 30 May 2013 20:40:43 +0000 Subject: Added the OnClosing callback to cLuaWindow API git-svn-id: http://mc-server.googlecode.com/svn/trunk@1534 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Debuggers/Debuggers.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'MCServer') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 076cec9ca..484ea88be 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -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); -- cgit v1.2.3