Sprite_Button menu question

So I've spent the last few days watching tutorials and I think I'm getting a decent grip on how scripts are handled. I'm trying to do a full replacement of the menu with a cellphone and I'm making progress but I'm running into an issue I'd like some help with.


As of now I have the phone displaying on the screen and the sprite buttons are selectable with the mouse. The problem is, I'm manually adding the buttons with addChild(). They don't exist as part of a collection of commands so you can't navigate through them with the arrows. What I'd like to be able to do is set the sprite buttons up in a grid like how the player name entry scene/window does. Then I could just overlay the grid of buttons over the picture of the phone.  


In rpg_windows.js i can see Window_NameInput and Window_Selectable. I think everything I need is here however I'm unsure how to do the same thing with sprite_buttons. I think I can probably figure this out given enough time, but if someone has a script with something similar they could share or can point me towards a tutorial that could help, I'd really appreciate it.


Thanks!


TerrorDoll

PhoneMenu.png
I put a few more hours into this and I think I'm getting closer. Looks like window_base has a drawItem() function that handles creating the look of the objects. I'm going to try overwriting it and seeing if I can get basic images to show. If that works I'll changes them over to Sprite_Buttons.


Any additional guidance is still appreciated!
A couple more hours in and a few steps closer. Still not there yet and I could really use some help.


As far as I can tell Window_Base kicks off drawAllItems which iterates through a collection and fires off drawItem as it increments. As draw item fires it passes along an index which is used all over the place, especially in Window_MenuStatus.


That seems pretty clear. All I have to do is set my rows and columns. Then every time drawitem fires, just create a rectangle, add a button and attach a handler to it. There is one problem though. I don't understand what the source collection is. I have no clue what I'm iterating through. There is obviously a collection because I have an index, but don't know what that collection contains or how to add to it. 


So lets say that I'd like to have 16 buttons laid out in a 4x4 grid. I set my maxItems to 16. I set maxCols to 4 and maxRows 4. But where do I set the backing collection? What am I iterating though in order to pass an index through the draw commands?


I'm a C# programmer and I have a sneaking suspicion that this is one of those times where having knowledge in a different language is hurting me because I'm expecting it to operate like C# and it's not.


Any ideas?
Well I figured it out. At least partially. In case anyone else is curious, the backing collection is actually set by maxItems. So if you set it to 16 you'll see your drawItems fired 16 times. It all makes sense now, but it's a weird way to set it up. 


Now I'll just add the buttons and pray the arrow navigation works correctly without too much fiddling on my part. 


Out of curiosity, is anyone interested in this script once I've finished with it? I wasn't able to find anything like it for MV. I don't know if that means no one has bothered to do it yet or if it hasn't been done because no one wants it. If there is some demand for it, I could take a few days, clean it up and release it.

Original thread: https://forums.rpgmakerweb.com/threads/sprite_button-menu-question.61089/