Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Recommended Posts

ghost9610    2

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 testingend

Also 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?

Share this post


Link to post
Share on other sites
squeek    230

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 testingend
Not sure what you're asking in the second question.

Share this post


Link to post
Share on other sites
ghost9610    2

@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?

Share this post


Link to post
Share on other sites