Nested Classes issue
anyone have any pointers for dealing with nested windows? basicly what I am trying to do is get a window to create a new copy of itself then be able to share information with the child. I tried creating a holding place in the class but the parents data doesnt seam to update with the childs...
so: window1 creates window2 window2 creates window3 change information in window3 window3 updates information for window2 then window2 updates window1 I have most of it togeather and figured out but I cant get them to recursivly update... here is my window sorry it is a little long, figured all information is better then not enough: Code:
I also havent built in any error control and still needs some clean up but just wanted to get the idea working first. at first I figured the tree nodes were not updating correctly so that is when I rebuilt the "spawnrec" and "elevate" functions to interact with the child directly... any pointers would be awesome, I am not a very good programmer but I am persistant and good and finding work arounds but this one has me stumped... |
Without looking into it too far, my first guess is you might be having namespace collision with multiple copies of the same class. I notice in your constructor & some of the method you define some variables like..
Code:
nestwin = AddItemWindow() Essentially what I'm getting at is perhaps the copy of "nextwin" in your click event function isn't referring to what you think its referring to when the code gets ran (but rather the last one to be defined. |
perhaps, but I was under the impression that in lua anything declared in a function was local to the function by default, but worth a shot.
|
garan is right about the data scope. i think it would be a better idea to do what you are trying to do by, making a class that contains your top level info. so say you want an array of a certain window. a class holding this info could be like (im doing this off the top of my head so bare with me.
cont = class() function cont:Cunstructor() self.winList = {} end function cont:addWindow(winObj, nameOf) self.winList[nameOf] = winObj end function cont:getWindow(nameOf) return self.winList[nameOf] end this is just a very simple example.. of how to maintain a collection of objects. nameOf can be a string like "title window" or you can make it interger base where it is 1 2 3 4 etc. so to use just do , myContainer = cont() --my window is a window class that you have made just make a new instance of it then pass it myContainer:addWindow(myWindow, "Main") to set data or grab position etc use local tempWindow = myContainer:getWindow("Main") local x, y = tempWindow:GetPosition() hope this makes some sense. ideally you would use your container class with self.mainWin = yourWindow in the constructor to save it in the class for future reference |
my idea was just to collect the data then let the window get garbage collected that was why i was trying to create a tree node, then have the children add the info into the parents tree node. and after setting some of the information local and passing the "tempnode" instead of the "tempnodes" up the tree it seams to almost work. the windows are more reliable and they are passing some of the information not all of their child nodes (as in depth 1 would work but depth 3 would not pass all the way back to 1)
on the point of keeping a list of windows, does anyone know how well the garbage collection works in lotro/lua? how many windows would it take to start slowing the client if I record each and every one of them? and how would I tell the client to kill a window other then setting it to not-visible? |
Quote:
|
ok, I can get the node to pass correctly but it is not passing the child nodes at all from what i can tell, even when i pass the children directly, which brings up another question can you add all child nodes at once or do you have to do it one by one?
as in: nodes = node:GetChildNode() parentnodes:Add(nodes) |
All times are GMT -5. The time now is 03:00 PM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI