View Single Post
Old 08-15-2017, 10:02 AM   #48
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

meanwhile i have noticed something interesting/ugly:
i am using a lib to help debug which is called: inspect
if this get's triggered once or multiple times:
Code:
function GUI.MyMenubox:onmouseup()	
    self:mouse_up()
    DBG("",true)
    DBG("Without any modification",true)
    DBG("-----------------------------------",true)
    DBG(inspect(GUI.elms_list),true)
    
   
    GUI.elms["my_lbl2"].color="magenta"
    GUI.elms["my_lbl3"].color="magenta"
    DBG("After setting element 2 and 3 to magenta",true)
    DBG("-----------------------------------",true)
    DBG(inspect(GUI.elms_list),true)   
end
this get's printed:
Code:
Without any modification
-----------------------------------
{ { "tabs" }, {}, { "my_lbl2", "my_lbl6", "my_lbl4", "my_mnu", "my_lbl3", "my_lbl1", "my_lbl5" },
  [0] = {}
}
After setting element 2 and 3 to magenta
-----------------------------------
{ { "tabs" }, {}, { "my_lbl2", "my_lbl6", "my_lbl4", "my_mnu", "my_lbl3", "my_lbl1", "my_lbl5" },
  [0] = {}
}
which seems normal, as the data structure is equal, altho i have no idea what "[0] ={}" means here...
but if i change the "z" and instead use the function like this:

Code:
function GUI.MyMenubox:onmouseup()	
    self:mouse_up()
    DBG("",true)
    DBG("Without any modification",true)
    DBG("-----------------------------------",true)
    DBG(inspect(GUI.elms_list),true)
    
    GUI.elms["my_lbl2"].z=333
    GUI.elms["my_lbl3"].z=334
    DBG("After setting a new 'z' to element 3",true)
    DBG("-----------------------------------",true)
    DBG(inspect(GUI.elms_list),true)         
end

this get's printed:

Code:
Without any modification
-----------------------------------
{ { "tabs" }, {}, { "my_lbl1", "my_mnu", "my_lbl3", "my_lbl2", "my_lbl6", "my_lbl4", "my_lbl5" },
  [0] = {}
}
After setting a new 'z' to element 3
-----------------------------------
{ { "tabs" }, {}, { "my_lbl1", "my_mnu", "my_lbl3", "my_lbl2", "my_lbl6", "my_lbl4", "my_lbl5" },
  [0] = {}
}
but second time look at what happens to the structure:

Code:
Without any modification
-----------------------------------
{ { "tabs" }, {}, { "my_lbl6", "my_lbl5", "my_lbl4", "my_mnu", "my_lbl1" },
  [0] = {},
  [333] = { "my_lbl2" },
  [334] = { "my_lbl3" }
}
After setting a new 'z' to element 3
-----------------------------------
{ { "tabs" }, {}, { "my_lbl6", "my_lbl5", "my_lbl4", "my_mnu", "my_lbl1" },
  [0] = {},
  [333] = { "my_lbl2" },
  [334] = { "my_lbl3" }
}
Notice the change to [333] = { "my_lbl2" }, [334] = { "my_lbl3" } in which [333] and [334] are the new "z" values and { "my_lbl3" } and { "my_lbl2" } are the elements with new "z".

I was not expecting when using GUI.elms["name"].z=666 to alter GUI.elms_list structure. So i wonder if this a normal behaviour?

Just in case you don't know and need inspector you can get here: https://github.com/kikito/inspect.lua and use with your req function to import . If you need me to send the files we'll figure out a way too.

Thank you

Last edited by deeb; 08-15-2017 at 11:20 AM.
deeb is online now   Reply With Quote