ghost9610 Posted May 16, 2014 Share Posted May 16, 2014 How can I change the content of the screen after clicking the button? *Change the Texts, and adding some textures into screen. I have this code, but when I click into button "Next" and open console's log (Ctrl+L) - It's don't write "ended!"local ButtonNextPage = self.menu:AddChild(ImageButton()) <..some parameters there..> ButtonNextPage:SetText("Next") ButtonNextPage:SetOnClick( self:ButtNextPage() )<..some code there..>function TestScreen:ButtNextPage() print("ended!") --for testingendAlso what I need to change:<..some code there..>self.page1 = self.root:AddChild(Text(BODYTEXTFONT, 20)) <..some parameters..> self.page1:EnableWordWrap(true) self.page1:SetString(STRINGS.TESTSCREEN_PAGE_1)So, how can I change the text and force the button to work? Link to comment https://forums.kleientertainment.com/forums/topic/36502-working-with-screens/ Share on other sites More sharing options...
squeek Posted May 16, 2014 Share Posted May 16, 2014 (edited) You're passing the return value (nil) of self:ButtNextPage() to SetOnClick instead of the function. To use a member function as a callback, you need to wrap it in another function like so: local ButtonNextPage = self.menu:AddChild(ImageButton()) <..some parameters there..> ButtonNextPage:SetText("Next") ButtonNextPage:SetOnClick( function() self:ButtNextPage() end ) <..some code there..> function TestScreen:ButtNextPage() print("ended!") --for testingendNot sure what you're asking in the second question. Edited May 16, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/36502-working-with-screens/#findComment-482237 Share on other sites More sharing options...
ghost9610 Posted May 16, 2014 Author Share Posted May 16, 2014 @squeek, thanks, button working. In second question I just asked for function OnUpdate (or something like this) - I just can't understand how do we call for this function? Link to comment https://forums.kleientertainment.com/forums/topic/36502-working-with-screens/#findComment-482333 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now