widget.newSwitch() Early comments/bugs/requests

Here’s one I think everyone could use. 99% of games out there have settings screens, and there is always something else you could want to use this for - even something as simple as a light! (All you gotta do is replace the button artwork!) Even better; this widget is three in one; you get checkboxes, you get radio buttons, and you get on/off switches.

on/off is clearly my favorite right now - it supports tap on/off as well as the user drag left/right stuff - but of all the new widgets this one is clearly the most ready for primetime.

Bugs:

  • Buttons default to center (Not filed)
    Not sure if I should file a bug on this since it’s exactly the same problem the other widgets have. I mean, maybe I’m wrong here, but setting top= and left= should be the topleft of the object, right?

  • Sometimes radio buttons don’t disengage on click? (Not filed)
    I can’t really report this one because a) no easy repro and b) it could just be OSX detecting unintended touches. The only thing that might say it’s not that is just that the console is registering the touches even if the art doesn’t update…anyway only seems to occur on the first couple of presses, and like I said, no easy repro and no idea if it does the same on device.

  • Doc bug: style setting (Not filed)
    For some reason the “style” setting is listed as only used for custom buttons. Pretty sure you need to set this to determine which of the three button types you have. It’s correctly an *optional* setting but the sample code makes it clear that you want to set this regardless of the theme in use.

  • Doc bug: two onPress types mentioned (Not filed)
    Which one is which? I’m not sure. The first one looks like it’s for the +/- button…

Requests:
-The big mystery is in the documentation as to which press function should be used. It says to use onPress/onRelease or onEvent, but not both. I can see the former are digital events befitting the button format, while the latter is the classic button format for the rest of Corona. Is that all this is, to provide the option to use either? Or is this to replicate specific functionality from iOS? Some illumination here would be great.
-Overview (API page) should probably mention the three types of buttons that can be made. Coming into this I thought only on/off was implemented!
-In an ideal world it would be awesome if the on/off switch supported vertical as well as horizontal orientation but that could mean enough code to equal a new function entirely…

It’s also worth noting that if for some reason you *do* use onEvent and onPress, onPress is always favored, onEvent is ignored, and there is no warning either way. (Probably unneccessary since it all has to be pre-configured) [import]uid: 41884 topic_id: 32663 reply_id: 332663[/import]

Thanks again Richard!

The default to center thing is common with all the widgets. I overlooked the fact that previously the other widgets defaulted to top left orientation ( I don’t know why ), so I will fix this asap for all of the new widgets.

I also agree that there should be more warnings and the documentation needs to be made clearer.

Cheers! [import]uid: 84637 topic_id: 32663 reply_id: 129885[/import]

Thanks again Richard!

The default to center thing is common with all the widgets. I overlooked the fact that previously the other widgets defaulted to top left orientation ( I don’t know why ), so I will fix this asap for all of the new widgets.

I also agree that there should be more warnings and the documentation needs to be made clearer.

Cheers! [import]uid: 84637 topic_id: 32663 reply_id: 129885[/import]