MZ How to set up scrolling windows ?

Hi, I'll would like to create a scrolling window. I was trying to do a sort of description window, displaying texts and some pictures. I've done it in base window then find out this was too much things to display in this type of window so I tried to switch in scrollable window and failed miserably. Sadly I cant figure out how to set them up. Ive try some experiment but with no results or understanding whatsoever. So here I am. Trying to seek help from people of knowledge ^^. Hope you can help me. Thx.
Hi there!
I think the best course on this kind of situation is for you to share the code so people can point out what you did wrong.
Like you said you failed. But failed how? That kind of details is better known if other people can see the code.
Firstly thx for your interest,
then sorry, I must have phrase it incorrectly. What I seek is pretty much someone showing me a step by step process line by line building a scrollable window like a tutorial.

Here is my test code:

Spoiler: Code
JavaScript:
//---------_---------_---------_---------_---------_---------_
//======================|~~| Functions |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

function getWinLH(mult) {
    return Window_Base.prototype.lineHeight()*mult;
}

//---------_---------_---------_---------_---------_---------_
//======================|~~| Windows |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯


function ScrollableWindowTest() {
    this.initialize(...arguments);
}

ScrollableWindowTest.prototype = Object.create(Window_Scrollable.prototype);
ScrollableWindowTest.prototype.constructor = ScrollableWindowTest;

ScrollableWindowTest.prototype.initialize = function(rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this._scrollX = 0;
    this._scrollY = 0;
    this._scrollBaseX = 0;
    this._scrollBaseY = 0;
    this.text = "Once upon a time in a long long contry"
    this.text2 = "There was a man struggling with scrollable windows"
    this.clearScrollStatus();
};

ScrollableWindowTest.prototype.paint = function() {
    this.drawText(this.text,0,0,375,'left');
    this.drawText(this.text,0,getWinLH(1),375, 'left');
    this.drawText(this.text,0,getWinLH(2),375, 'left');
    this.drawText(this.text,0,getWinLH(3),375, 'left');
    this.drawText(this.text,0,getWinLH(4),375, 'left');
    this.drawText(this.text,0,getWinLH(5),375, 'left');
    this.drawText(this.text,0,getWinLH(6),375, 'left');
    this.drawText(this.text,0,getWinLH(7),375, 'left');
    this.drawText(this.text2,0,getWinLH(8),375, 'left');
};

//---------_---------_---------_---------_---------_---------_
//======================|~~| Scene |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

class Scene_Test extends Scene_Base {
    constructor() {
        super();
        this.makeWindows();
    }

    makeWindows(){
        this.ScrollableWindowTest = new ScrollableWindowTest(new Rectangle(
            0,
            0,
            400,
            250));
        this.addChild(this.ScrollableWindowTest)
    };
};

I don't think there is much to see here. Cause I just pretty much change the window_base in window_scrollable and the refresh() in paint(). Try to put enough text and a window small enought. I've just CtrlC + V the code from the rmmz_windows cause I wanted to experiment, usualy I code like the scene class without the prototype. That all I can show, hope it will help you understand that I'm a lvl 0.
Thx again for trying to make me xp.
OK, so:
  1. For it to be a scrollable window, the paint method must account for the current scroll position. Let's look at Window_Selectable, which inherits from Window_Scrollable...
    Spoiler: window_selectable excerpts (rmmz_windows.js)
    JavaScript:
    Window_Base.prototype.itemHeight = function() {
        return this.lineHeight();
    };
    
    Window_Selectable.prototype.contentsHeight = function() {
        return this.innerHeight + this.itemHeight();
    };
    
    Window_Selectable.prototype.topRow = function() {
        return Math.floor(this.scrollY() / this.itemHeight());
    };
    
    Window_Selectable.prototype.maxCols = function() {
        return 1;
    };
    
    Window_Selectable.prototype.topIndex = function() {
        return this.topRow() * this.maxCols();
    };
    
    Window_Selectable.prototype.maxVisibleItems = function() {
        const visibleRows = Math.ceil(this.contentsHeight() / this.itemHeight());
        return visibleRows * this.maxCols();
    };
    
    Window_Selectable.prototype.drawAllItems = function() {
        const topIndex = this.topIndex();
        for (let i = 0; i < this.maxVisibleItems(); i++) {
            const index = topIndex + i;
            if (index < this.maxItems()) {
                this.drawItemBackground(index);
                this.drawItem(index);
            }
        }
    };
    You can see here that it only draws the items that are at least partially visible, based on .scrollY(): the current vertical scroll position. drawItem(index) draws the selectable item for the given index value, e.g.
    JavaScript:
    Window_ChoiceList.prototype.drawItem = function(index) {
        const rect = this.itemLineRect(index);
        this.drawTextEx(this.commandName(index), rect.x, rect.y, rect.width);
    };


  2. The Window_Scrollable vertical scroll logic depends on the window's overallHeight. As-is, Window_Scrollable defines its total content height (px) to be the height of the window's contents area, i.e. no scrolling:
    JavaScript:
    Window_Scrollable.prototype.overallHeight = function() {
        return this.innerHeight;
    };
    Window_Selectable overrides this to permit scrolling if appropriate, based on its row count:
    JavaScript:
    Window_Selectable.prototype.overallHeight = function() {
        return this.maxRows() * this.itemHeight();
    };


  3. You'll also need to update the scroll position, e.g. over time (marquee-style) or based on user input. The window's update method gets called every frame, so that's where you would handle scrolling. E.g.
    Spoiler: window_selectable update scroll/cursor position (rmmz_windows.js)
    JavaScript:
    Window_Selectable.prototype.update = function() {
        this.processCursorMove();
        this.processHandling();
        this.processTouch();
        Window_Scrollable.prototype.update.call(this);
    };
    
    Window_Selectable.prototype.processCursorMove = function() {
        if (this.isCursorMovable()) {
            const lastIndex = this.index();
            if (Input.isRepeated("down")) {
                this.cursorDown(Input.isTriggered("down"));
            }
    // ...
For your example, I think it would be far easier to inherit from Window_Selectable. Your choice, though~ 👋

(PS: style-wise, I would also suggest you follow the existing naming convention, e.g. Window_ScrollableDrackus rather than ScrollableWindowTest.)
Thanks a lot for your answer, this unlocked me. With all your information I experimented a bit and come up with this :

Spoiler: My test code
JavaScript:
function getWinLH(mult) {
    return Window_Base.prototype.lineHeight()*mult;
}

//---------_---------_---------_---------_---------_---------_
//======================|~~| Windows |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯


function Scrollable_WindowTest() {
    this.initialize(...arguments);
}

Scrollable_WindowTest.prototype = Object.create(Window_Scrollable.prototype);
Scrollable_WindowTest.prototype.constructor = Scrollable_WindowTest;

Scrollable_WindowTest.prototype.initialize = function(rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this._scrollY = 0;
    this._scrollBaseY = 1;
    this.text = "Once upon a time in a long long country"
    this.text2 = "There was a man struggling with scrollable windows"
    this.text3 = "but he could see the light"
    this.text4 = "a the end of the tunnel"
    this.text5 = "He may no longer struggle"
    this.text6 = "Or not"
    this.text7 = "but he hope soon"
    this.text8 = "cause he want to finish his pluggin"
    this.text9 = "as soon as possible"
    this.clearScrollStatus();
};

Scrollable_WindowTest.prototype.overallHeight = function() {
    return getWinLH(9);
};

Scrollable_WindowTest.prototype.scrollBlockHeight = function() {
    return 1;
};

Scrollable_WindowTest.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    this.processWheelScroll();
    this.processTouchScroll();
    this.updateSmoothScroll();
    this.updateScrollAccel();
    this.updateArrows();
    this.updateOrigin();
};

Scrollable_WindowTest.prototype.updateOrigin = function() {
    const blockHeight = this.scrollBlockHeight() || 1;
    const baseY = - this._scrollY - (this._scrollY % blockHeight);
    if (baseY !== this._scrollBaseY) {
        this.updateScrollBase(baseY);
        this.contents.clear();
        this.paint(baseY);
      
    }
    this.origin.y = this._scrollY % blockHeight;
};


Scrollable_WindowTest.prototype.paint = function(baseY) {
    this.drawText(this.text,0,baseY,375,'left');
    this.drawText(this.text2,0,baseY + getWinLH(1),375, 'left');
    this.drawText(this.text3,0,baseY + getWinLH(2),375, 'left');
    this.drawText(this.text4,0,baseY + getWinLH(3),375, 'left');
    this.drawText(this.text5,0,baseY + getWinLH(4),375, 'left');
    this.drawText(this.text6,0,baseY + getWinLH(5),375, 'left');
    this.drawText(this.text7,0,baseY + getWinLH(6),375, 'left');
    this.drawText(this.text8,0,baseY + getWinLH(7),375, 'left');
    this.drawText(this.text9,0,baseY + getWinLH(8),375, 'left');
};

It seems to works fine, if you can see something odd please feel free to point it out.

(PS: style-wise, I would also suggest you follow the existing naming convention, e.g. Window_ScrollableDrackus rather than ScrollableWindowTest.)

Actualy this is a test file, usualy I use something like this:
D78MZ_PluginName_Window_Title
Replace the "PluginName" by the plugin name. I'm doing a Bestiary Plugin so this is:
D78MZ_Bestiary_Window_Title
Same with Scene replacing Window or anything else.
I use this cause it help me staying organise and I'm sure I'll not make double.
I don't know if this follow the naming convention though.

So to summarize a bit when doing a scrollable window you need to make sure that:
- In the initialize put the _scrollX/Y and _scrollBaseX/Y depending the direction you want it to scroll.
- In the initialize put the clearScrollStatus()
- Your overallHeight/Width match the height/width of the contents and not the window's by changing the existing function.
- The y/x of your draw is linked with the Scrolling in some way.

First is this correct ? and then do you have something to add on this little list ?
It seems to works fine, if you can see something odd please feel free to point it out.
  1. I notice that you're drawing all the text every time, rather than only the lines that would be (partially) visible. Text drawn outside of the window's draw area won't appear. That's less efficient than what I suggested, but if it works for you then no worries~

  2. Instead of declaring 10 properties (text, text2, etc), it would be much more standard to use a single Array here. E.g.
    JavaScript:
        this.text = [
            "Once upon a time in a long long country",
            "There was a man struggling with scrollable windows",
            "but he could see the light",
            "a the end of the tunnel",
            "He may no longer struggle",
            "Or not",
            "but he hope soon",
            "cause he want to finish his pluggin",
            "as soon as possible"
        ];
    Then you could use a loop in the paint method, to draw the (relevant lines of) text from that array. Like the example I gave, with Window_Selectable.

  3. I'm not sure why you've defined a custom updateOrigin method, but maybe I'm missing something. this.contents.clear(); and coordinate checks would usually be in the paint method instead, e.g. Window_Selectable has:
    JavaScript:
    Window_Selectable.prototype.paint = function() {
        if (this.contents) {
            this.contents.clear();
            this.contentsBack.clear();
            this.drawAllItems();
        }
    };
    (drawAllItems decides which item indices to draw: see the first spoiler in my previous post.)

Actualy this is a test file, usualy I use something like this:
D78MZ_PluginName_Window_Title
Seems OK!

So to summarize a bit when doing a scrollable window you need to make sure that:
- In the initialize put the _scrollX/Y and _scrollBaseX/Y depending the direction you want it to scroll.
- In the initialize put the clearScrollStatus()
  • _scrollY is the current (vertical) scroll position: initialising it to a non-zero value will mean the window does not start with the topmost content fully visible.

  • Looks like _scrollBaseY lets you control the non-scrolling area, e.g. _scrollBaseY = -this.lineHeight() adds a single line of non-scrolling header space at the top. [Edit: on looking at it more closely, the scrollBase values actually store the "last painted" scroll position.] Unless you need that, you can just leave it at 0.
Same idea for _scrollX and _scrollBaseX. All of these properties are measured in pixels.

Usually you would just call the initialize method of Window_Scrollable (or super in class syntax), since you're inheriting from that. That method initialises the scroll properties. Maybe the prototype syntax is confusing you? E.g.
JavaScript:
Scrollable_WindowTest.prototype.initialize = function(rect) {
    Window_Scrollable.prototype.initialize.call(this, rect);
// ...

- Your overallHeight/Width match the height/width of the contents and not the window's by changing the existing function.
Technically you are writing a new function for your new window class, so that it doesn't just use the existing (unchanged) function from the inherited class. But otherwise, yes.

First is this correct ?
I think you've got the idea, yes. 👋
I notice that you're drawing all the text every time, rather than only the lines that would be (partially) visible. Text drawn outside of the window's draw area won't appear. That's less efficient than what I suggested, but if it works for you then no worries~

Instead of declaring 10 properties (text, text2, etc), it would be much more standard to use a single Array here. E.g.

I was just trying to make something scrollable, I didnt think of any optimization.
Now that I get the gist of it I'll try it. Thanks for tips, I had completly forgotten the array for the draw.

  1. I'm not sure why you've defined a custom updateOrigin method, but maybe I'm missing something. this.contents.clear(); and coordinate checks would usually be in the paint method instead, e.g. Window_Selectable has:

It's mainly for the minus in front of the this._scrollY to make it scroll the other way.
There surely a best way to do it but with just this code in front of my eyes I figure it out this would work as I want to.
const baseY = - this._scrollY - (this._scrollY % blockHeight);

Leading this I put the contents.clear in cause "the clear must come before the paint()" but forgot I could just put it in the beggining of paint(). Thx again for pointing it out.
  • _scrollY is the current (vertical) scroll position: initialising it to a non-zero value will mean the window does not start with the topmost content fully visible.

  • Looks like _scrollBaseY lets you control the non-scrolling area, e.g. _scrollBaseY = -this.lineHeight() adds a single line of non-scrolling header space at the top. Unless you need that, you can just leave it at 0.

Actualy when the _scrollY and _scrollBaseY were at 0 when the window open there is no content so I ve put the _scrollBaseY at 1 for the content do be display frame 1. Again there is surely a best way.

Maybe the prototype syntax is confusing you?
Yes a lot ...

Anyway thank you very much for all of this. I learn a lot.
It's mainly for the minus in front of the this._scrollY to make it scroll the other way.
Not sure what you mean by this, but if it does what you want then it's all OK~

Actualy when the _scrollY and _scrollBaseY were at 0 when the window open there is no content so I ve put the _scrollBaseY at 1 for the content do be display frame 1.
Instead, I think you could just add this.paint(); to the end of the initialize method?

On looking at the core updateScrollBase method more closely, I think I misinterpreted the purpose of the _scrollBase values in my previous post. It looks like they're actually to track the "last-painted" scroll positions (I've added an edit my previous post):
  • To eliminate unnecessary repaints; and
  • To reposition all scrollable child sprites appropriately.
That's why _scrollBaseY = 1 and _scrollY = 0 causes your window to immediately repaint:
JavaScript:
    const baseY = - this._scrollY - (this._scrollY % blockHeight);
    if (baseY !== this._scrollBaseY) {
On that subject, updateScrollBase expects 2 arguments: baseX and baseY. You may want to replace this line in your code to avoid setting _scrollBaseY = undefined:
JavaScript:
        this.updateScrollBase(baseY);
...with this:
JavaScript:
        this.updateScrollBase(0, baseY);
Otherwise I think your window will repaint every frame (and any inner sprites may glitch/vanish, too).
Not sure what you mean by this, but if it does what you want then it's all OK~

Basicly, this line:
JavaScript:
const baseY = - this._scrollY - (this._scrollY % blockHeight);
was
JavaScript:
const baseY = this._scrollY - (this._scrollY % blockHeight);

I changed the this._scrollY in - this._scrollY so the scroll go downward instead of upward.
As I said there must me another way but at the time I figure out this will work.
Instead, I think you could just add this.paint(); to the end of the initialize method?

I'll try this.

On that subject, updateScrollBase expects 2 arguments: baseX and baseY. You may want to replace this line in your code to avoid setting _scrollBaseY = undefined:
JavaScript:
this.updateScrollBase(baseY);
...with this:
JavaScript:
this.updateScrollBase(0, baseY);
Otherwise I think your window will repaint every frame (and any inner sprites may glitch/vanish, too).

Ok thank you very much.
I ve got a new problem with it: when I draw a picture in the scrollable window, the picture is not confine in the window like the text can be. How can I do for the picture to appear bit by bit when it enter the window?

For now Ive not yet use the code to draw the items that are at least partially visible. But I guess and maybe wrong that It will have the same problem. When the picture will be partially visible it will display the full picture regarless of the window. Ive been thinking of using a setFrame() linked with this but there is maybe a better solution.

Spoiler: My test code
JavaScript:
//---------_---------_---------_---------_---------_---------_
//======================|~~| Functions |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

function getWinLH(mult) {
    return Window_Base.prototype.lineHeight()*mult;
}

//---------_---------_---------_---------_---------_---------_
//======================|~~| Windows |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯


function Scrollable_WindowTest() {
    this.initialize(...arguments);
}

Scrollable_WindowTest.prototype = Object.create(Window_Scrollable.prototype);
Scrollable_WindowTest.prototype.constructor = Scrollable_WindowTest;

Scrollable_WindowTest.prototype.initialize = function(rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this._scrollY = 0;
    this._scrollBaseY = 0;
    this.text = ["Once upon a time in a long long country",
        "There was a man struggling with scrollable windows",
        "but he could see the light",
        "a the end of the tunnel",
        "He may no longer struggle",
        "Or not",
        "but he hope soon",
        "cause he want to finish his pluggin",
        "as soon as possible",]
    this.paint(- this._scrollY);
    this.clearScrollStatus();
};

Scrollable_WindowTest.prototype.overallHeight = function() {
    return getWinLH(15);
};

Scrollable_WindowTest.prototype.scrollBlockHeight = function() {
    return 1;
};

Scrollable_WindowTest.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    this.processWheelScroll();
    this.processTouchScroll();
    this.updateSmoothScroll();
    this.updateScrollAccel();
    this.updateArrows();
    this.updateOrigin();
};

Scrollable_WindowTest.prototype.updateOrigin = function() {
    const blockHeight = this.scrollBlockHeight() || 1;
    const baseY = - this._scrollY - (this._scrollY % blockHeight);
    if (baseY !== this._scrollBaseY) {
        this.updateScrollBase(0, baseY);
        this.paint(baseY);
  
    }
    this.origin.y = this._scrollY % blockHeight;
};


Scrollable_WindowTest.prototype.paint = function(baseY) {
    this.contents.clear();
    ImageManager.clear();
    for(let i = 0; i < this.text.length; i++) {
        this.drawText(this.text[i],0,baseY + getWinLH(i),375,'left')
    };
    this.PictureTest = new Sprite_PictureTest(ImageManager.loadEnemy("Goblin"));
    this.addChild(this.PictureTest);
    this.PictureTest.y = baseY + getWinLH(this.text.length) + 10;
};

//---------_---------_---------_---------_---------_---------_
//=====================|~~| Picture |~~|======================>
//---------¯---------¯---------¯---------¯---------¯---------¯

class Sprite_PictureTest extends Sprite {
    constructor(bitmap) {
        super(bitmap);
        this.x = 60;
        this.yBase = 0;
    }

    update() {
        super.update();
    }
}


//---------_---------_---------_---------_---------_---------_
//======================|~~| Scene |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

class Scene_Test extends Scene_Base {
    constructor() {
        super();
        this.makeWindows();
    }

    makeWindows(){
        this.Scrollable_WindowTest = new Scrollable_WindowTest(new Rectangle(
            0,
            0,
            400,
            250));
        this.addChild(this.Scrollable_WindowTest)
    };
};

Edit: I have done some test and this code seems to work. What do you think about it ?


Spoiler: My test code
JavaScript:
//---------_---------_---------_---------_---------_---------_
//======================|~~| Functions |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

function getWinLH(mult) {
    return Window_Base.prototype.lineHeight()*mult;
}

//---------_---------_---------_---------_---------_---------_
//======================|~~| Windows |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯


function Scrollable_WindowTest() {
    this.initialize(...arguments);
}

Scrollable_WindowTest.prototype = Object.create(Window_Scrollable.prototype);
Scrollable_WindowTest.prototype.constructor = Scrollable_WindowTest;

Scrollable_WindowTest.prototype.initialize = function(rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this._scrollY = 0;
    this._scrollBaseY = 0;
    this.picHeight;
    this.picWidth;
    this.text = ["Once upon a time in a long long country",
        "There was a man struggling with scrollable windows",
        "but he could see the light",
        "a the end of the tunnel",
        "He may no longer struggle",
        "Or not",
        "but he hope soon",
        "cause he want to finish his pluggin",
        "as soon as possible",]
    this.paint(0);
    this.clearScrollStatus();
};

Scrollable_WindowTest.prototype.overallHeight = function() {
    return getWinLH(25);
};

Scrollable_WindowTest.prototype.scrollBlockHeight = function() {
    return 1;
};

Scrollable_WindowTest.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    this.processWheelScroll();
    this.processTouchScroll();
    this.updateSmoothScroll();
    this.updateScrollAccel();
    this.updateArrows();
    this.updateOrigin();
};

Scrollable_WindowTest.prototype.updateOrigin = function() {
    const blockHeight = this.scrollBlockHeight() || 1;
    const baseY = - this._scrollY - (this._scrollY % blockHeight);
    if (baseY !== this._scrollBaseY) {
        this.updateScrollBase(0, baseY);
        this.paint(baseY);
       
    }
    this.origin.y = this._scrollY % blockHeight;
};

Scrollable_WindowTest.prototype.paint = function(baseY) {
    this.contents.clear();
    ImageManager.clear();
    for(let i = 0; i < this.text.length; i++) {
        let posYTextDraw = baseY + getWinLH(i);
        if( 250 > posYTextDraw > 0 ){
            this.drawText(this.text[i],0,posYTextDraw,375,'left')
        };  
    };
    let posYPicDraw = baseY + getWinLH(this.text.length) + 20;
    let margePic = 17;
    this.PictureTest = new Sprite_PictureTest(ImageManager.loadEnemy("Goblin"));
    this.addChild(this.PictureTest);
    this.picHeight = this.PictureTest._texture.baseTexture.height;
    this.picWidth = this.PictureTest._texture.baseTexture.width;
    this.PictureTest.y = posYPicDraw;
    this.PictureTest.visible = false;
    if(250 > posYPicDraw && posYPicDraw > margePic) {
        this.PictureTest.visible = true;
        let picPlus = (posYPicDraw + this.picHeight) - 250;
        if(picPlus > - margePic){
            this.PictureTest.setFrame(0,0,this.picWidth, this.picHeight - picPlus - margePic);
        };
    } else if ( margePic > posYPicDraw && posYPicDraw > - this.picHeight) {
        this.PictureTest.visible = true;
        this.PictureTest.y = margePic;
        let picLess = posYPicDraw + this.picHeight;
        let picYLess = this.picHeight - picLess;
        this.PictureTest.setFrame(0,picYLess,this.picWidth,picLess);
    };
};

//---------_---------_---------_---------_---------_---------_
//=====================|~~| Picture |~~|======================>
//---------¯---------¯---------¯---------¯---------¯---------¯

class Sprite_PictureTest extends Sprite {
    constructor(bitmap) {
        super(bitmap);
        this.x = 60;
    }

    update() {
        super.update();
    }
}


//---------_---------_---------_---------_---------_---------_
//======================|~~| Scene |~~|========================>
//---------¯---------¯---------¯---------¯---------¯---------¯

class Scene_Test extends Scene_Base {
    constructor() {
        super();
        this.makeWindows();
    }

    makeWindows(){
        this.Scrollable_WindowTest = new Scrollable_WindowTest(new Rectangle(
            0,
            200,
            400,
            250));
        this.addChild(this.Scrollable_WindowTest)
    };
};
I notice your update method looks identical to the one inherited from Window_Scrollable? So you could probably remove it.

Also, sprites update their size to match their assigned bitmap once that bitmap has finished loading, so I don't think you need to check the _texture to get width/height? For layout changes that depend on bitmap size, you can use Bitmap#addLoadListener. For an example, see the _onBitmapChange & _onBitmapLoad methods of Sprite (rmmz_core.js).

How can I do for the picture to appear bit by bit when it enter the window?
Rather than using addChild(sprite) the usual approaches are either:
  1. Paint the picture's bitmap to scroll-based coordinates, like the scrollable text.
    • E.g. see the drawFace method of Window_Base (rmmz_windows.js).
    • Note that this requires the source image to be in memory when you paint it.

  2. Alternatively, make the picture an "inner child", so it gets scrolled with the other content.
    • E.g. see the addInnerChild method of Window (rmmz_core.js).
    • The updateScrollBase method of Window_Scrollable moves inner children appropriately.
The core scripts do a bit of both, e.g. the pause menu status window (Window_MenuStatus) blits the actor faces like text, but places the HP/MP/TP gauges (Sprite_Gauge) as inner children (see the createInnerSprite method of Window_StatusBase for details).
Thx for your reply, you are really the goat.
I notice your update method looks identical to the one inherited from Window_Scrollable? So you could probably remove it.
I was testing some other things with the update but leave it there when copying the code that's why it's here but it will be remove ^^

Also, sprites update their size to match their assigned bitmap once that bitmap has finished loading, so I don't think you need to check the _texture to get width/height? For layout changes that depend on bitmap size, you can use Bitmap#addLoadListener. For an example, see the _onBitmapChange & _onBitmapLoad methods of Sprite (rmmz_core.js).

I needed the width/height for the set.frame() that I was putting on the picture for the "ilusion" that the picture was an innerChild. I don't know if this is the right way to get this information thought. I need it too for my pluging where Ive made a redimension function depending on the windows width. So if there is a better way I'll take it.

Rather than using addChild(sprite) the usual approaches are either:
  1. Paint the picture's bitmap to scroll-based coordinates, like the scrollable text.
    • E.g. see the drawFace method of Window_Base (rmmz_windows.js).
    • Note that this requires the source image to be in memory when you paint it.

Unfortunately this one can't be done cause in my plugin the picture change due to a command so I'll need to load all picture beforehand and I don't know if this is less consuming for the plugin to do this.

Alternatively, make the picture an "inner child", so it gets scrolled with the other content.
  • E.g. see the addInnerChild method of Window (rmmz_core.js).
  • The updateScrollBase method of Window_Scrollable moves inner children appropriately.

So I've just test this one and it seems to work perfectly.

Again thanks a lot for enlighting me, I'll look the part in the rmmz_core.js that you point out.
So I've just test this one and it seems to work perfectly.
Great! 😂

I needed the width/height for the set.frame() that I was putting on the picture for the "ilusion" that the picture was an innerChild.
So, like, you have this line:
JavaScript:
this.picHeight = this.PictureTest._texture.baseTexture.height;
I'm pretty sure it could just have been:
JavaScript:
this.picHeight = this.PictureTest.height;
Both cases assume the bitmap is already in memory, though, which isn't necessarily true. In future, if you need to reference a bitmap's size you can use addLoadListener: this sets a function to be run when the image is loaded. (If the image is already in memory, the function will run immediately.) That function can do the necessary adjustments~
Spoiler: addloadlistener example from one of my plugins
JavaScript:
/** Requests redraw of message face. */
requestMessageFace: function() {
    const f = this.faceName;
    if (f)
        ImageManager.loadFace(f).addLoadListener(
            this.drawMessageFace.bind(this, f)
        );
}
This waits for the image to be loaded before calling the associated drawMessageFace method:
JavaScript:
/**
 * @param {string} loadedName face name when loading started
 * @param {Bitmap} bmp loaded bitmap
 * @returns {boolean} `true` iff face was drawn.
 */
drawMessageFace: function(loadedName, bmp) {
    if (loadedName === this.faceName) {  // don't draw this face if faceName has changed
// ...
So, like, you have this line:
JavaScript:
this.picHeight = this.PictureTest._texture.baseTexture.height;
I'm pretty sure it could just have been:
JavaScript:
this.picHeight = this.PictureTest.height;
Both cases assume the bitmap is already in memory, though, which isn't necessarily true. In future, if you need to reference a bitmap's size you can use addLoadListener: this sets a function to be run when the image is loaded. (If the image is already in memory, the function will run immediately.) That function can do the necessary adjustments~
The first time I tried this
JavaScript:
this.PictureTest.height
it didn't work but can't remember why. Maybe it was just a synthax error at the end, since the information didn't work I tried to work around and start getting it with the
JavaScript:
Texture.height
. I just retry the one you mention now and it work perfectly ...
That was surely a synthax error or something like that. Anyway that made me retry it so thank you for your comment.

I would like to really made you understand how you unlocked me for the scrollable windows I was pretty stuck and my plugin wasn't progressing. This part was like 90% of my problems and is pretty much finish thanks to you. Now it's just getting the data in to be display in this window (and doing some optimization in the code). Much are ready but some are more tricky and need the JSON.parse() that I don't know much about but I'll get it done nonetheless. And if I got problem I'll ask for some help ^^. So really a big thank you. I've learn a lot and feel more confortable with scrollable windows now.

I don't know if this thread need to be [resolve]/close or something like this but I'm sure it can help some people who would like to learn about scrollable windows.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-set-up-scrolling-windows.182423/