Widget 2.0 Buttons And Onrelease

With the new widget library, I’ve noticed that the onRelease has been removed. You can still set it in the parameters (when you’re creating a button) but you’re no longer able to do this:

[lua]

button.onRelease=myFunc

[/lua]

This is actually devastating to me, as I do all of my onRelease setting after I create my buttons. I can’t just move over to putting all of my buttons after the onRelease, because I have references to them, and I can’t put all of the functions at the top of my code because I have references to them, too.

Can this please be added? Right now I’m attempting to create my own function to change the widget onTouch event to support self.onRelease. I have a feeling that’s not the best practice :slight_smile:

C

With the new widget library, I’ve noticed that the onRelease has been removed. You can still set it in the parameters (when you’re creating a button) but you’re no longer able to do this:

[lua]

button.onRelease=myFunc

[/lua]

This is actually devastating to me, as I do all of my onRelease setting after I create my buttons. I can’t just move over to putting all of my buttons after the onRelease, because I have references to them, and I can’t put all of the functions at the top of my code because I have references to them, too.

Can this please be added? Right now I’m attempting to create my own function to change the widget onTouch event to support self.onRelease. I have a feeling that’s not the best practice :slight_smile:

C

You can do it now, just different than before.

button._view._onRelease = myfunction

Hey, Danny, can we reset any of the widget button parameters the same way?  I mean, if I can change some parameters of the widget v1.0 buttons after they are created, can the same parameters be changed using _ button._view. _ after the widget v2.0 buttons are created?  Or does it work only with onRelease?  

When I started working on migrating to widget v2.0, I noticed onRelease wasn’t the only item that caused me problems, and I gave up and reverted back to widget v1.0.  I don’t remember which parameters they were, but if I can use the same approach (i.e., using _ button._view. _ to change things the way I can with widget v1.0), it would make it a little less painful for me to migrate to widget v2.0. 

Naomi

@Danny:

Thanks for the explanation!

Would you mind putting something that says that or explains it in the documentation? I was worried for quite some time.

C

With the new widget library, I’ve noticed that the onRelease has been removed. You can still set it in the parameters (when you’re creating a button) but you’re no longer able to do this:

[lua]

button.onRelease=myFunc

[/lua]

This is actually devastating to me, as I do all of my onRelease setting after I create my buttons. I can’t just move over to putting all of my buttons after the onRelease, because I have references to them, and I can’t put all of the functions at the top of my code because I have references to them, too.

Can this please be added? Right now I’m attempting to create my own function to change the widget onTouch event to support self.onRelease. I have a feeling that’s not the best practice :slight_smile:

C

You can do it now, just different than before.

button._view._onRelease = myfunction

Hey, Danny, can we reset any of the widget button parameters the same way?  I mean, if I can change some parameters of the widget v1.0 buttons after they are created, can the same parameters be changed using _ button._view. _ after the widget v2.0 buttons are created?  Or does it work only with onRelease?  

When I started working on migrating to widget v2.0, I noticed onRelease wasn’t the only item that caused me problems, and I gave up and reverted back to widget v1.0.  I don’t remember which parameters they were, but if I can use the same approach (i.e., using _ button._view. _ to change things the way I can with widget v1.0), it would make it a little less painful for me to migrate to widget v2.0. 

Naomi

@Danny:

Thanks for the explanation!

Would you mind putting something that says that or explains it in the documentation? I was worried for quite some time.

C

help me I need this button to lead me to another .lua file

local playbutton = widget.newButton

{

    left = 186,

    top = 160,

    width = 105,

    height = 105,

    defaultFile = “button.png”,

    overFile = “button click.png”,

    onEvent = handleButtonEvent,

    onRelease = game

}

Please do not hijack threads.  Any one wishing to respond to @Max281’s question please do so here: http://forums.coronalabs.com/topic/41853-i-need-button-help/

help me I need this button to lead me to another .lua file

local playbutton = widget.newButton

{

    left = 186,

    top = 160,

    width = 105,

    height = 105,

    defaultFile = “button.png”,

    overFile = “button click.png”,

    onEvent = handleButtonEvent,

    onRelease = game

}

Please do not hijack threads.  Any one wishing to respond to @Max281’s question please do so here: http://forums.coronalabs.com/topic/41853-i-need-button-help/