How to scroll up/down multiple rows in inventory?

Started by bx83, Sat 07/08/2021 03:37:21

Previous topic - Next topic

bx83

I've previously used the MouseWheelNorth/South buttons to do this, in which it scrolls 1 page at a time.

Using the same command (invCustomInv.ScrollDown()/Up()) with a key (I'm using eKeyPageUp/Down) it only scrolls 1 row at a time (out of the 4 visible rows).

Is there any way to have the invWindow scroll up/down multiple rows?

Crimson Wizard

#1
Quote from: bx83 on Sat 07/08/2021 03:37:21
Is there any way to have the invWindow scroll up/down multiple rows?

Formally speaking, you may just call the scroll function multiple times.

Not sure what you are trying to accomplish though. Do you want it to scroll all the way down, or scroll exactly X times every time a key is pressed?

bx83

Exactly 4 lines per scroll, as this is a 'page' of the inventory.

All good, fixed :)

Code for the uninitiated:
Code: ags
function on_key_press(eKeyCode keycode)
{
...
//scroll through inventory using page-up/down
  if (keycode == eKeyPageUp && gInventory.Visible) {
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
  }
  if (keycode == eKeyPageDown && gInventory.Visible) {
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
  }
...
}

Crimson Wizard

You could probably also do

Code: ags

invCustomInv.TopItem += invCustomInv.ItemsPerRow * 4;

SMF spam blocked by CleanTalk