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
https://forums.kleientertainment.com/forums/topic/36502-working-with-screens/
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. Edited by squeek

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...