Where to extend the widget library?

In this corona tutorial:

https://coronalabs.com/blog/2014/04/08/widgets-creating-a-sliding-panel/

and a few others, the widget library is extended with a new function

function widget.newPanel( options ) local customOptions = options or {} local opt = {} opt.location = customOptions.location or "top" etc...

Where is the best place to put this code? Right now I have put it in main.lua, and it works completely fine when I add it in in the other scenes. However, it seems a bit messy to put it there - could I move to another file or is there a better way?

Thanks :slight_smile:

I believe the best place to put it is main.Lua because it is the file it reads first.
Tyler Jacobson

You can create a .lua file named “extras.lua” or “utility.lua” (what I do) and have it in there. When you require that file, your widget.* functions will become part of the widget namespace (assuming you require widget first.)

Rob

I believe the best place to put it is main.Lua because it is the file it reads first.
Tyler Jacobson

You can create a .lua file named “extras.lua” or “utility.lua” (what I do) and have it in there. When you require that file, your widget.* functions will become part of the widget namespace (assuming you require widget first.)

Rob