Class ContextMenu

  • All Implemented Interfaces:
    com.badlogic.gdx.scenes.scene2d.utils.Cullable, com.badlogic.gdx.scenes.scene2d.utils.Layout
    Direct Known Subclasses:
    GaiaSkyContextMenu

    public class ContextMenu
    extends com.badlogic.gdx.scenes.scene2d.ui.Table
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ContextMenu.ContextMenuListener
      Listener used to get events from ContextMenu.
      static class  ContextMenu.ContextMenuStyle  
      • Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table

        com.badlogic.gdx.scenes.scene2d.ui.Table.Debug, com.badlogic.gdx.scenes.scene2d.ui.Table.DebugRect
    • Field Summary

      • Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table

        backgroundBottom, backgroundLeft, backgroundRight, backgroundTop, debugActorColor, debugCellColor, debugTableColor
    • Constructor Summary

      Constructors 
      Constructor Description
      ContextMenu​(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T extends com.badlogic.gdx.scenes.scene2d.Actor>
      com.badlogic.gdx.scenes.scene2d.ui.Cell<T>
      add​(T actor)  
      void addItem​(MenuItem item)  
      void addSeparator()  
      boolean contains​(float x, float y)  
      void draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)  
      MenuItem getActiveItem()  
      com.badlogic.gdx.scenes.scene2d.InputListener getDefaultInputListener()
      Returns input listener that can be added to scene2d actor.
      com.badlogic.gdx.scenes.scene2d.InputListener getDefaultInputListener​(int mouseButton)
      Returns input listener that can be added to scene2d actor.
      ContextMenu.ContextMenuListener getListener()  
      boolean remove()  
      static void removeAll​(com.badlogic.gdx.scenes.scene2d.Stage stage)
      Removes every instance of ContextMenu form Stage actors.
      void setListener​(ContextMenu.ContextMenuListener listener)  
      protected void setStage​(com.badlogic.gdx.scenes.scene2d.Stage stage)  
      void showMenu​(com.badlogic.gdx.scenes.scene2d.Stage stage, float x, float y)
      Shows menu as given stage coordinates
      void showMenu​(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.scenes.scene2d.Actor actor)
      Shows menu below (or above if not enough space) given actor.
      • Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table

        add, add, add, add, add, add, align, background, background, bottom, center, clearChildren, columnDefaults, debug, debug, debugActor, debugAll, debugCell, debugTable, defaults, drawBackground, drawDebug, drawDebugBounds, getAlign, getBackground, getCell, getCells, getClip, getColumnMinWidth, getColumnPrefWidth, getColumns, getColumnWidth, getMinHeight, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getPrefWidth, getRow, getRowHeight, getRowMinHeight, getRowPrefHeight, getRows, getSkin, getTableDebug, hit, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, removeActor, reset, right, row, setBackground, setBackground, setClip, setDebug, setRound, setSkin, stack, top
      • Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup

        childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
      • Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group

        act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, computeTransform, drawChildren, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
      • Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

        addAction, addCaptureListener, addListener, ancestorsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ContextMenu

        public ContextMenu​(com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
                           java.lang.String styleName)
    • Method Detail

      • removeAll

        public static void removeAll​(com.badlogic.gdx.scenes.scene2d.Stage stage)
        Removes every instance of ContextMenu form Stage actors.

        Generally called from ApplicationListener.resize(int, int) to remove menus on resize event.

      • add

        public <T extends com.badlogic.gdx.scenes.scene2d.Actor> com.badlogic.gdx.scenes.scene2d.ui.Cell<T> add​(T actor)
        Overrides:
        add in class com.badlogic.gdx.scenes.scene2d.ui.Table
      • addItem

        public void addItem​(MenuItem item)
      • addSeparator

        public void addSeparator()
      • getDefaultInputListener

        public com.badlogic.gdx.scenes.scene2d.InputListener getDefaultInputListener()
        Returns input listener that can be added to scene2d actor. When right mouse button is pressed on that actor, menu will be displayed
      • getDefaultInputListener

        public com.badlogic.gdx.scenes.scene2d.InputListener getDefaultInputListener​(int mouseButton)
        Returns input listener that can be added to scene2d actor. When mouse button is pressed on that actor, menu will be displayed
        Parameters:
        mouseButton - from Input.Buttons
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.Batch batch,
                         float parentAlpha)
        Overrides:
        draw in class com.badlogic.gdx.scenes.scene2d.ui.Table
      • showMenu

        public void showMenu​(com.badlogic.gdx.scenes.scene2d.Stage stage,
                             float x,
                             float y)
        Shows menu as given stage coordinates
        Parameters:
        stage - stage instance that this menu is being added to
        x - stage x position
        y - stage y position
      • showMenu

        public void showMenu​(com.badlogic.gdx.scenes.scene2d.Stage stage,
                             com.badlogic.gdx.scenes.scene2d.Actor actor)
        Shows menu below (or above if not enough space) given actor.
        Parameters:
        stage - stage instance that this menu is being added to
        actor - used to get calculate menu position in stage, menu will be displayed above or below it
      • contains

        public boolean contains​(float x,
                                float y)
      • setStage

        protected void setStage​(com.badlogic.gdx.scenes.scene2d.Stage stage)
        Overrides:
        setStage in class com.badlogic.gdx.scenes.scene2d.Group
      • remove

        public boolean remove()
        Overrides:
        remove in class com.badlogic.gdx.scenes.scene2d.Actor
      • getActiveItem

        public MenuItem getActiveItem()