[ALOY-359] buttongrid Widget and orientation change

GitHub Issuen/a
Resolution Date2012-12-07T22:30:33.000+0000
Affected Version/sn/a
Fix Version/sAlloy 0.3.4, 2012 Sprint 25
ReporterRick Blalock


We're using the built in widget "ButtonGrid" (which is documented very well btw). Everything works fine but I wanted to point out a potential issue with using the orientationchange global event: https://github.com/appcelerator/alloy/blob/master/widgets/com.appcelerator.buttongrid/controllers/widget.js#L167 While this is innocent if the developer only plans on having one instance of the buttongrid that's always in memory, imagine if there are multiple instances that are meant to go out of scope. The user would have created a memory leak if he hadn't looked at the source code, realized this was there, and manually removed the event. Three possible options: 1. Remove it completely and let the user assign an orientation event to the Widget.relayout() method on his own. 2. Have some type of remove method that will remove it for the user 3. Document that the user must remove it manually. I prefer #1.


  1. Tony Lukasavage 2012-12-07 I think I'm going to do a little bit of a mix of #1 and #2. I'm going to add a configuration option to the init() called *autoLayout*, which will be *true* by default to maintain compatibility with any existing uses of this widget. If *autoLayout* is set to true, then the developer will be required to free the gesture handler manually with a new destroy() function. If *autoLayout* is set to false, the gesture handler will not be created automatically, but the developer will need to handle orientation changes themselves if they so choose.
  2. Tony Lukasavage 2012-12-07 Latest inline docs for the buttongrid widget can be found here: https://github.com/appcelerator/alloy/blob/master/widgets/com.appcelerator.buttongrid/controllers/widget.js They detail the use of the new *autoLayout* property and *destroy()* function.

JSON Source