PDA

View Full Version : How does one programmatically resize a window?



Minty23185Fresh
November 9th, 2017, 05:19
I'm working with masterindex in campaign_masterindex.xml.

As I had guessed, the number of custom filters for the NPC library editor is large. When the NPC editor opens for the first time the controls overlap each other. It would be amusing if it wasn't so ugly.

The window is spawned in the toggleIndex() function in the DesktopManager. If I put setSize() and setPosition() function calls in toggleIndex() I can easily resize the window to my desired height. But I'd prefer to place those functions within the script of masterindex (in masterindex_window.lua) because that is where all of my other code is already.

I have tried placing the setSize() and setPosition() function calls in the onInit() of masterindex_window.lua of my extension, in the onInit() of masterindex_window.lua of the ruleset, and I've tried calling those functions in the ruleset using super.setSize() from my extension. All without success. No errors are thrown. The window just doesn't refresh to the new size.

As a last resort I tried getting a handle on the window using the Interface.findwindow() function from the onInit() but that didn't work either.

Any other hints would be greatly appreciated. Thanks in advance.

Bidmaron
November 9th, 2017, 05:44
I believe setSize and setPosition only change the controls/windows in memory and not their source definitions in the code file. Therefore, no onInit call in an extension is going to have an effect. Similarly, any onInit of any control/window script file is going to get called before the control is created. You have two choices. You can either defer control creation through use of the fastinit tag or by some other technique I cannot remember. Search for fastinit, and you will find at least one discussion of what you are trying to do. The problem is that controls are instantiated before the window containing them is fully initialized.

Minty23185Fresh
November 9th, 2017, 06:05
Thanks Bidmaron. It appears as though it isn't as simple as I had hoped. I'll have to proceed with the solution that works, at the time the window is instantiated.