From ac4f66fff2131b74d1a087252c3c914fb1b73ca1 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 19 Dec 2015 18:32:43 +0800 Subject: [PATCH] fix lua focus test --- .../CocoStudioGUITest/CocoStudioGUITest.lua | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index e5d876470e..114cd78764 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -2341,6 +2341,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._horizontalLayout = ccui.HBox:create() self._horizontalLayout:setPosition(cc.p(20, winSize.height / 2 + 40)) @@ -2474,6 +2483,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create() self._verticalLayout:setPosition(cc.p(winSize.width/2 - 100, winSize.height - 70)) @@ -2607,6 +2625,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create() @@ -2772,6 +2799,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._horizontalLayout = ccui.HBox:create() @@ -2937,6 +2973,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create()