PDA

View Full Version : I Just Want to Change the Frame of a Subwindow



PneumaPilot
December 2nd, 2008, 19:01
I have searched all over these forums to fins some way of just simply accessing a subwindow and changing its frame. This should be easy, but I think that it is obscured by some arcane syntax. I have tried:


window.page2.subwindow.setFrame("newframe");

I have also tried:


local cs = Interface.findWindow("charsheet",getDatabaseNode());

if cs then
cs.page2.subwindow.setFrame("charsheethunter");
end


The first one says that page2 is nil. The second said that I improperly called findWindow. I just want to change the frame graphic of all tabbed pages of the character sheet at once.

PneumaPilot
December 2nd, 2008, 20:27
Okay, I figured it out. You cannot access the subwindow by the code I listed above until it is created. Therefore, you need to put any frame changing code in the onInstanceCreated function.

PneumaPilot
December 2nd, 2008, 20:52
Dang! Everything works perfectly, but the very FIRST time that I change to page 2 after opening a character sheet, I get an error: "attempt to index field 'subwindow' a nil value." Even though I get this error, the code still does all that it is supposed to, and I never get the error again after the first time.

PneumaPilot
December 2nd, 2008, 20:57
Okay, I figured it out again. Since I call the onInstanceCreated function from within the activateTab function of the tabcontrol template, I just put a test for subwindow existence in the onInstanceCreated function, since the code will get run twice anyway. The first time it runs, the window is not yet in existence, but when the activateTab function calls it, it is. Problem solved, albeit messily.

Foen
December 2nd, 2008, 21:53
I don't think you need to call onInstanceCreated - it will be invoked by the FG engine once the subwindow has been instantiated.

PneumaPilot
December 2nd, 2008, 22:03
Yeah, I know, but - for better or ill - that's where I put the code to switch out the frame and text color info, so I invoke it from the activateTab function. You think I could just put all that code in activateTab? But there are other elements that use tabcontrol that aren't related to the main character sheet. I just couldn't find the most appropriate place for it, so it ended up in the first place that I got it working.

Foen
December 2nd, 2008, 22:15
I don't think you need to invoke it from activateTab: I think activation triggers onInstanceCreated, so you don't need to call it directly. It's been a while since I last played with this area of the FG engine, so I may be a little rusty :)

Stuart

PneumaPilot
December 2nd, 2008, 22:20
It didn't work until I invoked it from there. If I changed a bead one time after opening the character sheet, the colors, etc. would change perfectly. But when I changed it more than once, then my second and third page stayed the same colors from the first change. That's when I added the onInstanceCreated call to the activateTab function.

Foen
December 3rd, 2008, 05:57
Ahh, my bad.