Home Kwiksher Forums Kwik4 Passing command to another page
-
otterslidestudio@aol.com
ParticipantApril 22, 2020 at 1:17 am #86048One thing that I have never been able to understand is how to pass a command to a page from an overlay. Any tips on how this is accomplished? For example, if I wanted to use setfillcolor to change the color of an object in in a page from a button in the overlay?
Yamamoto
KeymasterApril 22, 2020 at 7:22 pm #86049A global variable or dispatching an event to the page will work to interact from the overlay page. I will check the behavior today.
Yamamoto
KeymasterApril 22, 2020 at 11:51 pm #86051myListener.lua in the page’s external code
—
Runtime:addEventListener( “myEvent”, function(event)
print(“event.text”)
end)
—myDispatcher.lua in the button of overlay
—
Runtime:dispatchEvent({ name=”myEvent”, text=”Changed By dispatchEvent” })
—Alternatively use a global varibale set with Kwik
myListener.lua in the page’ external code
—
Runtime:addEventListener( “enterFrame”, function(event)
print(_K.myVar)
end)
—myDispatcher.lua in the button of overlay
—
_K.myVar = “Changed From Overlay”
—For instance, in an external code, you can access a displayObject with layer.YOUR_LAYER_NAME
if _K.myVar == "Blue" then layer.YOUR_LAYER_NAME:setFillColor(0, 0, 1) -- R, G, B end
You can get a value from Overlay to set it to the function.
otterslidestudio@aol.com
ParticipantMay 3, 2020 at 8:15 pm #86073How would I remove this event listener?
Yamamoto
KeymasterMay 3, 2020 at 9:21 pm #86075OK, the listener was an anonymous function. let’s give it a function name to remove it later
local myListener = function(event) print(“event.text”) end -- Remove Runtime:addEventListener( “myEvent”, myListener) -- Add Runtime:removeEventListener( “myEvent”, myListener)
otterslidestudio@aol.com
ParticipantMay 4, 2020 at 5:34 pm #86077Thank you. I was having trouble figuring out that one on my own.
-
AuthorPosts
You must be logged in to reply to this topic.