Jump to content

Recommended Posts

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?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

×
  • Create New...