widget.newtabbar and baseDir - "The defaultFile passed does not exists"

Dear Corona community,

what I’d like to do:

Create a tabbar with images located in DocumentsDirectory as tabButtons

My code:

-- set fallback button local profileButton = { width = 25, height = 25, defaultFile = "menuHeart.png", overFile = "menuHeartFilled.png", onPress = function() composer.gotoScene("newsfeed") end } -- if profilepicture exists on device, use it as a tabButton local path = system.pathForFile( "profilepicture.jpg", system.DocumentsDirectory) local fhd = io.open( path ) if(fhd) then fhd:close() profileButton = { width = 25, height = 25, defaultFile = "profilepicture.jpg", overFile = "profilepicture.jpg", baseDir = system.DocumentsDirectory, onPress = function() composer.gotoScene("newsfeed") end } end -- create menu options local tabButtons = { { width = 25, height = 25, defaultFile = "home.png", overFile = "home-filled.png", selected = true, onPress = function() composer.gotoScene("dofaver") end }, { width = 25, height = 25, defaultFile = "add.png", overFile = "add-filled.png", onPress = function() composer.gotoScene("addFirst") end }, profileButton, { width = 25, height = 25, defaultFile = "profile.png", overFile = "profile-filled.png", onPress = function() composer.gotoScene("friends") end }, { width = 25, height = 25, defaultFile = "settings.png", overFile = "settings-filled.png", onPress = function() composer.gotoScene("setAccount") end } } tabBar = widget.newTabBar( { height = 50, top = display.actualContentHeight + display.screenOriginY - 50, x = screenOriginX, buttons = tabButtons, backgroundFile = "tabbarTransparent.png", tabSelectedLeftFile = "tabbarTransparent.png", tabSelectedMiddleFile = "tabbarTransparent.png", tabSelectedRightFile = "tabbarTransparent.png", tabSelectedFrameWidth = 0, tabSelectedFrameHeight = 0 } )

Does this work?

No, I get a “The defaultFile passed for tab 3 does not exist” error, even though fileCheck returns true. When I don’t have the profilepicture.jpg in DocumentsDirectory, fileCheck returns - of course - false and I get the fallback-button no problem.

Any ideas?

Thanks :slight_smile:

Ok, now it’s getting weird: As soon as I set baseDir = system.DocumentsDirectory in a tabButton table, the requested file has to exist in BOTH resourceDirectory AND DocumentsDirectory.

As long as the file does exist in both folders, the tabbar works. As soon as I remove the file from either Documents or ResourceDirectory, I get the same error again.

That doesn’t make sense to me…

Looks like you need to make a mini-project and file a bug.

https://developer.coronalabs.com/content/bug-submission

I made a demo project here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/09/tabBar_documentsDirectory.zip

Copy the files in the folder ‘copyThesImages2Documents’ into your documents directory and then run it.

It demonstrates the issue you mentioned.

PS - Double check the docs to be sure this is a bug.  I didn’t and I wonder if baseDir is supported for discrete images or not.  It seems like it should be, but I’ll leave it to you to confirm this.

Great support as always, Ed. Thank you!

Yes, your demo project does exactly what I mentioned. As long as I have your graphic files in BOTH Documents and ResourceDirectory, it works, but as soon as I remove them from either Documents or Root Folder, the error occurs.

One should expect that as long as the files are in the folder that baseDir specifies, it should be cool.

I triple checked the docs before I posted here, but this part here (https://docs.coronalabs.com/api/library/widget/newTabBar.html:

Tab Buttons Within each sub-table of the buttons table (see Configuring Tab Buttons), you may add additional parameters to visually customize the button. Note that individual buttons can have a unique style according to the specified images. baseDir (optional) Constant. The base directory where the custom image is located. Default is your project folder (system.ResourceDirectory).

makes me interpret the whole thing as “should be doable”.

Guess I’ll file a bug report then :slight_smile:

Ok, now it’s getting weird: As soon as I set baseDir = system.DocumentsDirectory in a tabButton table, the requested file has to exist in BOTH resourceDirectory AND DocumentsDirectory.

As long as the file does exist in both folders, the tabbar works. As soon as I remove the file from either Documents or ResourceDirectory, I get the same error again.

That doesn’t make sense to me…

Looks like you need to make a mini-project and file a bug.

https://developer.coronalabs.com/content/bug-submission

I made a demo project here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/09/tabBar_documentsDirectory.zip

Copy the files in the folder ‘copyThesImages2Documents’ into your documents directory and then run it.

It demonstrates the issue you mentioned.

PS - Double check the docs to be sure this is a bug.  I didn’t and I wonder if baseDir is supported for discrete images or not.  It seems like it should be, but I’ll leave it to you to confirm this.

Great support as always, Ed. Thank you!

Yes, your demo project does exactly what I mentioned. As long as I have your graphic files in BOTH Documents and ResourceDirectory, it works, but as soon as I remove them from either Documents or Root Folder, the error occurs.

One should expect that as long as the files are in the folder that baseDir specifies, it should be cool.

I triple checked the docs before I posted here, but this part here (https://docs.coronalabs.com/api/library/widget/newTabBar.html:

Tab Buttons Within each sub-table of the buttons table (see Configuring Tab Buttons), you may add additional parameters to visually customize the button. Note that individual buttons can have a unique style according to the specified images. baseDir (optional) Constant. The base directory where the custom image is located. Default is your project folder (system.ResourceDirectory).

makes me interpret the whole thing as “should be doable”.

Guess I’ll file a bug report then :slight_smile: