Skip to main content
mikemwagm
Inspiring
February 2, 2024
Answered

How to force a ScriptUI docked panel to resize/update

  • February 2, 2024
  • 2 replies
  • 1083 views

Hi, I've been trying to figure this out for days now. I've searched everything I can think to search and can't find a suitable answer.

 

I have a function that hides a child panel. This works fine, but leaves a space where the panel used to be. If I manually resize my docked window it fixes the issue, but I want it to do this automatically without manually resizing. Is there a way to force the docked window to resize? Or is there some other way to do this?

 

I'm using .layout() and an onResize function to accomplish what I have so far. I've tried playing with the windows max size but again, this doesn't show until a resize happens and it only affects the inner elements, not the actual docked window size. I've tried using a notify("onResize") but it always throws an error saying notify is undefined. I'm missing some fundamental understanding here, but I don't know what.

 

To summarize what I want to do: When a button is clicked in a docked window, I want to hide a panel in that window and have the extra space hidden too, without having to manually resize. I also want to reverse this. 

Here's a small portion of my code to show you where I'm at with this:

function buttonHelpTestDown () {
            var maxSize = pnl.grp.maximumSize;
            if (pnl.grp.groupControls.groupTools.groupBuildCurvePreset.panelBuildCurve.maximumSize[0] > 0) {
                pnl.grp.groupControls.groupTools.groupBuildCurvePreset.panelBuildCurve.maximumSize = [0,0];
            } else {
                pnl.grp.groupControls.groupTools.groupBuildCurvePreset.panelBuildCurve.maximumSize = maxSize;
            }
            //prevent draw panel from disappearing
            var drawSize = pnl.grp.panelGridDraw.size;
            pnl.grp.panelGridDraw.minimumSize = drawSize;
            //refresh layout
            pnl.layout.layout(true);
            //reset draw panel min size
            pnl.grp.panelGridDraw.minimumSize = [0,0];
        }

        pnl.layout.resize();
        pnl.onResizing = pnl.onResize = function() {
            this.layout.resize();
        }

I'm so close to getting this to work right. Any help would be appreciated!

 

Thanks.

This topic has been closed for replies.
Correct answer mikemwagm

The solution that worked for me was using maximumSize to adjust my dominant panels size to remove the blank space. Nothing fancy just: hidden panel was (amout goes here) pixels high, add that many pixels to the dominant panel. And then reverse it when revealed. I only needed to use 

pnl.layout.layout(true);

to update the panels.

2 replies

mikemwagm
mikemwagmAuthorCorrect answer
Inspiring
February 12, 2024

The solution that worked for me was using maximumSize to adjust my dominant panels size to remove the blank space. Nothing fancy just: hidden panel was (amout goes here) pixels high, add that many pixels to the dominant panel. And then reverse it when revealed. I only needed to use 

pnl.layout.layout(true);

to update the panels.

Inspiring
February 3, 2024

My understanding is that the docked panel is outside of the script's control. It's passed to the script (this) so you can add elements into it, but the actual panel is part of AE's main UI and outside of the script's scope. It's only with non-docked scripts (Run from the File > Scripts menu) that a script has control over the main container.

mikemwagm
mikemwagmAuthor
Inspiring
February 5, 2024

Thanks, Paul. I kind of assumed that, but it doesn't hurt to ask. So, I'm still looking for a solution. There must be some way to force it update/redraw. Is there a way I could use onDraw to make this work? If I did something like:

pnl.grp.groupControls.groupTools.notify("onDraw");

All my attempts with this have always given me an error saying notify is undefined. I'm going about this wrong, but I don't know how.