Skip to content

Pop ups

Giorgio Garofalo edited this page Feb 9, 2021 · 4 revisions

In Chorus, a pop-up is like a post-it which is attached to the screen and remains in its place until it's removed.
There are three types of pop-ups: Text, TextFlow and Image. All of them have X and Y coordinates which refer to screen coordinates instead of scene ones.
A pop-up can be removed by calling hide() on its instance.

Text pop-up

A simple text pop-up can be displayed by calling showTextPopup(text, x, y).

const popup = showTextPopup('Hello Chorus API', getWindowX() + 200, getWindowY() + 200);
// ...
popup.hide();

Text pop-up

TextFlow pop-up

Similar to the previous one, a TextFlow - a JavaFX node - is a label with various parts formatted in different ways. In a nutshell, TextFlows are used wherever a text preview is present.
The API provides a function that automatically parses a colored text into a TextFlow: coloredTextToNode(text, useVariables) (placeholders will be replaced if useVariables is true). Note that this method automatically replaces "&" into the chosen color prefix by calling translateColorPrefixes(text, prefix).

showTextFlowPopup(coloredTextToNode('&dHi &5Chorus &d&nAPI'), getWindowX() + 200, getWindowY() + 200);

TextFlow pop-up

Image pop-up

An image pop-up displays an image on a rounded background by calling showImagePopup(image, x, y, width, height) where image is an Image instance and width and height are optional and define image size.

showImagePopup(new Image('chorus.png'), getWindowX() + 200, getWindowY() + 200, 50, 50);

Just a friendly reminder! For testing purposes, you can call getChorusIcon() to have a basic (but cool) image easily.

Image pop-up