Skip to content

Navigating Between Views

Natan Vieira edited this page May 30, 2023 · 22 revisions

Navigation between screens is a built-in feature in IF that allows you to move between screens in a simple way.

Table of Contents

Basic Usage

This example opens the A view when the player clicks in a item in the B view.

class A extends View {

    @Override
    public void onFirstRender(RenderContext render) {
        // Moves player to "B" view on click
        render.firstSlot(...).onClick(click -> click.open(B.class));
    }

}

class B extends View { ... }

It is possible to return to the previous screen using .back() the name of this is "Browsing History" as soon as a screen is opened from another this function will take the player back to the previous screen.

class A extends View {

    @Override
    public void onFirstRender(RenderContext render) {
        // Moves player to "B" view on click
        render.firstSlot(...).onClick(click -> click.open(B.class));
    }

}

class B extends View {

    @Override
    public void onFirstRender(RenderContext render) {
        // Moves player back to "A" view
        render.firstSlot(...).onClick(click -> click.back());
    }

}
Clone this wiki locally