Understanding Modular coding (creating a modular tabBar

ok, I just read the following page carefully which answered first 3 questions and I have got it working:

http://coronalabs.com/blog/2012/08/28/how-external-modules-work-in-corona/

I will try and see if I can get the scenario in question 4 working as well. 

Thanks,

There are some issues here. First you are defining everything global which is a bad thing and can eventually slow down and/or break you code. Make sure you use the word local in front of everything. If you want to able to access the values outside the module then set them on the module table like so:

t = {}

t.font = native.systemFont
t.fontBold = native.systemFontBold
t.statusBarH = display.topStatusBarContentHeight
t.tabBarH = 120
t.isAndroid = “Android” == system.getInfo(“platformName”)

local function func1()

end

t.func1 = func1

You can’t get 4 to work because you defined the meth1 inside the func3. If you need to call meth1 outside the func3 then define it separately in add a reference to it in the module table like func1 above.

Then when you need anything from the global.lua after you require it with local global = require(“global”) access the values with global.font and functions with global.func1().

Excellent, thanks. Very well explained and it is much clearer to me and my code is like the way i wanted. 

I have read elsewhere in the forum and from what I understand this functionality is dropped now but just to get a confirmation can I ask if I can unslelect a button from tabBar. For eg: In the common nav bar I have a “back” button which works fine i.e. when touched takes me to the previous/parent screen but the button continues to be selected. So if the user selects this back button and is taken to the previous screen the user cannot tap on the same back button again as it is already selected and therefore the only option is to select some other button (which unslelects back button) and then tap on back button.

I have tried comObj.tabBar:setSelected(0, false) or try to set selection to something else but it only simulates the touch event for other button and the back button continues to be selected.

Ideally there should be a way to unselect all the buttons but if that is not possible, can suggest a practical work around please.

Thanks,

That is because the tab bar is not meant for this kind of use. It is meant to select the scene or view where one is always active thus it remains pressed. If you need buttons that perform a specific function and return to unpressed state then I would recommend creating a group with normal buttons (widget.newButton).

Thank you very much, makes sense. I have resorted to Buttons and everything is working fine.