how can I see a group content?

hi corona gurus!!

I would want see all objects in a group, with their properties, to identify each object. How I can do it?

local stage = display.getCurrentStage() 

local newgroup = display.newGroup 

display.newGroup = function(…)

    local group = newgroup(unpack({…}))

    

    dispatchEvent{ name=“newGroup”, target=group, arg={…} }

    return group

end

regards!!

Try the following code:

-- == --    string:rpad( len, char ) - Places padding on right side of a string, such that the new string is at least len characters long. -- == function string:rpad(len, char)     local theStr = self     if char == nil then char = ' ' end     return theStr .. string.rep(char, len - #theStr) end -- == --    table.dump( theTable [, padding] ) - Dumps indexes and values inside single-level table (for debug) -- == function table.dump(theTable, padding )     local padding = padding or 30     print("\Table Dump:")     print("-----")     if(theTable) then         for k,v in pairs(theTable) do              local key = tostring(k)             local value = tostring(v)             local keyType = type(k)             local valueType = type(v)             local keyString = key .. " (" .. keyType .. ")"             local valueString = value .. " (" .. valueType .. ")"              keyString = keyString:rpad(padding)             valueString = valueString:rpad(padding)             print( keyString .. " == " .. valueString )          end     else         print("empty")     end     print("-----\n") end -- == --    table.print\_r( theTable ) - Dumps indexes and values inside multi-level table (for debug) -- == table.print\_r = function ( t )      local print\_r\_cache={}     local function sub\_print\_r(t,indent)         if (print\_r\_cache[tostring(t)]) then             print(indent.."\*"..tostring(t))         else             print\_r\_cache[tostring(t)]=true             if (type(t)=="table") then                 for pos,val in pairs(t) do                     if (type(val)=="table") then                         print(indent.."["..pos.."] =\> "..tostring(t).." {")                         sub\_print\_r(val,indent..string.rep(" ",string.len(pos)+1))                         print(indent..string.rep(" ",string.len(pos)+1).."}")                     elseif (type(val)=="string") then                         print(indent.."["..pos..'] =\> "'..val..'"')                     else                         print(indent.."["..pos.."] =\> "..tostring(val))                     end                 end             else                 print(indent..tostring(t))             end                     end     end     if (type(t)=="table") then         print(tostring(t).." {")         sub\_print\_r(t," ")         print("}")     else         sub\_print\_r(t," ")     end end ----- -----  Now do this on the group you want to explore ----- table.dump( group ) -- Single level dump  of 'group' -- OR  table.print\_r( group )  -- Recursive dump of 'group'  

Note: This will not print Corona functions or fields.  I don’t currently know of a way to dump those off of display objects.  They are hidden (or perhaps part  of _userdata)?

thank you very much, for your answer,but one question.

My problem is that I want to filter only a few objects, to apply them the “dispatchEvent”, not all objects in the group.

So I wanted to see the group’s content, but with the function , still see the tables like …’ table: 0345667 ",

can not see the name of the object or any of its properties???

Sorry I’m a begginer and I see that I have much to learn still

  1. Objects don’t have names.  You can store references to them in variables, and the variables can ‘act’ as names, but object ID are just numeric ‘table’ handles.

  2. No, as far as I know you cannot dump the default fields (what you are calling properties I believe) and functions attached to objects. i.e. All display objects have the field ‘isVisible’.  This will not dump using dump() or print_r().

  3. You can only dump user added (read as added in Lua) fields and functions.

Try the following code:

-- == --    string:rpad( len, char ) - Places padding on right side of a string, such that the new string is at least len characters long. -- == function string:rpad(len, char)     local theStr = self     if char == nil then char = ' ' end     return theStr .. string.rep(char, len - #theStr) end -- == --    table.dump( theTable [, padding] ) - Dumps indexes and values inside single-level table (for debug) -- == function table.dump(theTable, padding )     local padding = padding or 30     print("\Table Dump:")     print("-----")     if(theTable) then         for k,v in pairs(theTable) do              local key = tostring(k)             local value = tostring(v)             local keyType = type(k)             local valueType = type(v)             local keyString = key .. " (" .. keyType .. ")"             local valueString = value .. " (" .. valueType .. ")"              keyString = keyString:rpad(padding)             valueString = valueString:rpad(padding)             print( keyString .. " == " .. valueString )          end     else         print("empty")     end     print("-----\n") end -- == --    table.print\_r( theTable ) - Dumps indexes and values inside multi-level table (for debug) -- == table.print\_r = function ( t )      local print\_r\_cache={}     local function sub\_print\_r(t,indent)         if (print\_r\_cache[tostring(t)]) then             print(indent.."\*"..tostring(t))         else             print\_r\_cache[tostring(t)]=true             if (type(t)=="table") then                 for pos,val in pairs(t) do                     if (type(val)=="table") then                         print(indent.."["..pos.."] =\> "..tostring(t).." {")                         sub\_print\_r(val,indent..string.rep(" ",string.len(pos)+1))                         print(indent..string.rep(" ",string.len(pos)+1).."}")                     elseif (type(val)=="string") then                         print(indent.."["..pos..'] =\> "'..val..'"')                     else                         print(indent.."["..pos.."] =\> "..tostring(val))                     end                 end             else                 print(indent..tostring(t))             end                     end     end     if (type(t)=="table") then         print(tostring(t).." {")         sub\_print\_r(t," ")         print("}")     else         sub\_print\_r(t," ")     end end ----- -----  Now do this on the group you want to explore ----- table.dump( group ) -- Single level dump  of 'group' -- OR  table.print\_r( group )  -- Recursive dump of 'group'  

Note: This will not print Corona functions or fields.  I don’t currently know of a way to dump those off of display objects.  They are hidden (or perhaps part  of _userdata)?

thank you very much, for your answer,but one question.

My problem is that I want to filter only a few objects, to apply them the “dispatchEvent”, not all objects in the group.

So I wanted to see the group’s content, but with the function , still see the tables like …’ table: 0345667 ",

can not see the name of the object or any of its properties???

Sorry I’m a begginer and I see that I have much to learn still

  1. Objects don’t have names.  You can store references to them in variables, and the variables can ‘act’ as names, but object ID are just numeric ‘table’ handles.

  2. No, as far as I know you cannot dump the default fields (what you are calling properties I believe) and functions attached to objects. i.e. All display objects have the field ‘isVisible’.  This will not dump using dump() or print_r().

  3. You can only dump user added (read as added in Lua) fields and functions.