Search in sources :

Example 1 with BaseInteractionListener

use of org.terasology.rendering.nui.BaseInteractionListener in project Terasology by MovingBlocks.

the class BrowserWidget method onDraw.

@Override
public void onDraw(Canvas canvas) {
    hyperlinkBoxes.clear();
    canvas.addInteractionRegion(new BaseInteractionListener() {

        @Override
        public boolean onMouseClick(NUIMouseClickEvent event) {
            for (HyperlinkBox hyperlinkBox : hyperlinkBoxes) {
                if (hyperlinkBox.box.contains(event.getRelativeMousePosition())) {
                    for (BrowserHyperlinkListener browserHyperlinkListener : listenerList) {
                        browserHyperlinkListener.hyperlinkClicked(hyperlinkBox.hyperlink);
                    }
                    break;
                }
            }
            return true;
        }
    });
    if (displayedPage != null) {
        DocumentRenderer.drawDocumentInRegion(displayedPage, canvas, canvas.getCurrentStyle().getFont(), canvas.getCurrentStyle().getTextColor(), canvas.size(), register);
    }
}
Also used : BaseInteractionListener(org.terasology.rendering.nui.BaseInteractionListener) NUIMouseClickEvent(org.terasology.rendering.nui.events.NUIMouseClickEvent)

Aggregations

BaseInteractionListener (org.terasology.rendering.nui.BaseInteractionListener)1 NUIMouseClickEvent (org.terasology.rendering.nui.events.NUIMouseClickEvent)1