MZ Problem with Items background in Windows.Selectable

Hi all, I've made a plugin that creates selectables from an array.
Everything works great until the refresh function is called more than once.

There is a visual bug where the selectables' background keeps getting darker every time the refresh function is called

T1XxXK.png

l2vX8d.png


The refresh code is this:

JavaScript:
    Window_StatSkill.prototype.refresh = function() {
      this.contents.clear();
      this.drawAllItems();
    };

The text is cleaned but the background of the selectable seem to remain and every time drawAllItems is called a new background is stacked on the old one.
I tried to use clear in various functions but no success for now. Any idea?
That's because the background rectangles are painted to contentsBack, which you aren't clearing. However, if your window inherits from Window_Selectable then you shouldn't need to define a new refresh method, i.e. you should be able to just delete this code from your plugin:
JavaScript:
    Window_StatSkill.prototype.refresh = function() {
      this.contents.clear();
      this.drawAllItems();
    };
Many thanks, I deleted the whole refresh function and now it works well!
I went to check in rmmz_windows and yes, it was missing contentBacks.clear anyway

Really appreciated!
Great, you're welcome! 👋

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-items-background-in-windows-selectable.159750/