Problem with scene object

I a have an app with two views, but my problem is that I have an object in one of the views that I inserted, but it is appearing on the second view. 

Here are two screenshots: the one with the orange text is the first view and the black one with the only white text field is the second view. 

Why is it appearing even though I inserted it into the sceneGroup?

The only way that can happen (win display objects) is if you are not successfully inserting the object in the group you think you are.

Better double and triple check your code, look for case errors in your variable names.

Native Objects

This should work with the (native) text field object too, but I’m not going to rule out some weirdness because it is a native text object.

I am willing to look at your project if you zip the entire thing and send me a link to the zip file via PM.

I typically move, then destroy native objects when I change scenes.  

You cannot treat native objects like display objects in all cases.  

Corona bends over backwards to make them behave similarly, but you must remember they are owned by the OS, not Corona so the OS gets the final word on placement, sizing, fonts, etc.

Native objects are not true children of the sceneGroup.

If the sceneGroup is moved or destroyed, it will attempt to move/destroy the native object, but I suspect that composer scene changes are more subtle than this, thus the oddness you are encountering.

What I would like to do eventually with this is have a button that creates a newTextField (for categories of garbage) and another textField for its amount and a green button to add a new subcategory.

I changed two files in your project.  See: main.lua and view1.lua and look for initials EFM

Thank you!

I am going to have a table of these categories. So would I have to change the line to:

categories[i].isVisible = true

But then I would have to deal with problems of scope, because I would have to remove the local nameCategory.

I will reply back if I need more help.

I don’t know.  I guess so.  It is up to you how to manage the references to your text fields. :unsure:

PS - I forgot to mention this, but I don’t think you need to use composer at all for this.  You could simply create a set of display groups, and when you click a button:

  1. hide all the groups
  2. show just the group associated with that button.

This will solve all your text field is visible at the wrong time problems.

I don’t want to discourage you from using and learning composer.* but this is not how I would use it and I think it adds a level of complexity that is unnecessary for the application you are writing.

Thanks for the tip.

Better to implement this now then later.

:lol:

It would be something like:

group.isVisible = false

Is this correct?

I found out, this is the right way to do it. Way easier then composer so far.

I am having the same problem, the textField still appears in the wrong place. I am going to PM you my code.

How do I have button that creates a new textField, inserts it into a table, and also positions it below the previous textField?

I am a bit confused on how that would work. Are there any examples similar to this that I could use?

The only way that can happen (win display objects) is if you are not successfully inserting the object in the group you think you are.

Better double and triple check your code, look for case errors in your variable names.

Native Objects

This should work with the (native) text field object too, but I’m not going to rule out some weirdness because it is a native text object.

I am willing to look at your project if you zip the entire thing and send me a link to the zip file via PM.

I typically move, then destroy native objects when I change scenes.  

You cannot treat native objects like display objects in all cases.  

Corona bends over backwards to make them behave similarly, but you must remember they are owned by the OS, not Corona so the OS gets the final word on placement, sizing, fonts, etc.

Native objects are not true children of the sceneGroup.

If the sceneGroup is moved or destroyed, it will attempt to move/destroy the native object, but I suspect that composer scene changes are more subtle than this, thus the oddness you are encountering.

What I would like to do eventually with this is have a button that creates a newTextField (for categories of garbage) and another textField for its amount and a green button to add a new subcategory.

I changed two files in your project.  See: main.lua and view1.lua and look for initials EFM

Thank you!

I am going to have a table of these categories. So would I have to change the line to:

categories[i].isVisible = true

But then I would have to deal with problems of scope, because I would have to remove the local nameCategory.

I will reply back if I need more help.

I don’t know.  I guess so.  It is up to you how to manage the references to your text fields. :unsure:

PS - I forgot to mention this, but I don’t think you need to use composer at all for this.  You could simply create a set of display groups, and when you click a button:

  1. hide all the groups
  2. show just the group associated with that button.

This will solve all your text field is visible at the wrong time problems.

I don’t want to discourage you from using and learning composer.* but this is not how I would use it and I think it adds a level of complexity that is unnecessary for the application you are writing.

Thanks for the tip.

Better to implement this now then later.

:lol:

It would be something like:

group.isVisible = false

Is this correct?

I found out, this is the right way to do it. Way easier then composer so far.

I am having the same problem, the textField still appears in the wrong place. I am going to PM you my code.