Class ExtensionsKt

  • All Implemented Interfaces:

    
    public final class ExtensionsKt
    
                        
    • Constructor Detail

    • Method Detail

      • draggable

         final static <S extends Drawable> S draggable(S $self, Boolean withX, Boolean withY, Boolean free, Function1<S, Unit> onStart, Function1<S, Unit> onDrag, Function1<S, Unit> onDrop)

        Make this component draggable.

        Parameters:
        free - if this is true, the component will be able to be dragged outside its parent.
      • addHoverInfo

         final static <S extends Drawable> S addHoverInfo(S $self, String text)

        Add some text that is shown when the mouse is left still over this drawable for 1 second or more.

        Since:

        1.0.3

      • onChangeString

         final static <S extends Text> S onChangeString(S $self, Function2<S, String, Boolean> func)

        Add a listener for changes to the given String-type property.

        In PolyUI, this is for Text and TextInput only.

        Since:

        1.0.6

      • onChangeState

         final static <S extends Drawable> S onChangeState(S $self, Function2<S, Boolean, Boolean> func)

        Add a listener for changes to the given Boolean-type property.

        In PolyUI, this is for Checkbox and Switch only.

        Since:

        1.0.6

      • onChangeIndex

         final static <S extends Drawable> S onChangeIndex(S $self, Function2<S, Integer, Boolean> func)

        Add a listener for changes to the given Int-type property.

        In PolyUI, this is for Radiobutton, and Dropdown only.

        Since:

        1.0.6

      • onChangeNumber

         final static <S extends Drawable> S onChangeNumber(S $self, Function2<S, Float, Boolean> func)

        Add a listener for changes to the given Float-type property.

        In PolyUI, this is for Slider only.

        Since:

        1.0.6

      • setPalette

         final static <S extends Drawable> S setPalette(S $self, Function1<Colors, Colors.Palette> palette)

        Set the color palette of this drawable during initialization, using the PolyUI colors instance.

      • setFont

         final static <S extends Text> S setFont(S $self, Function1<FontFamily, Font> font)

        Set the font of this text component during initialization, using the PolyUI fonts instance.

        Since:

        1.1.3

      • addValidationFunction

         final static <S extends Text> S addValidationFunction(S $self, Function2<S, String, Boolean> func)

        Add a validation function to this text component.

        The given func will have the text that is requested as the argument. Return false to cancel the change, meaning the text will not be set.

      • setState

         final static <S extends Drawable> S setState(S $self, Byte state)

        Set the palette of this drawable according to one of the three possible component states in PolyUI.

        Parameters:
        state - the state to set.
      • prioritize

         final static <S extends Drawable> S prioritize(S $self)

        Prioritize this drawable, meaning it will, in relation to its siblings:

        • be drawn last

        • receive events first

        this method is experimental as it may interfere with statically-typed references to children.

        Since:

        1.0.0

      • relegate

         final static <S extends Drawable> S relegate(S $self)

        Relegate this drawable, meaning it will, in relation to its siblings:

        • be drawn first

        • receive events last

        this method is experimental as it may interfere with statically-typed references to children.

        Since:

        1.1.71

      • countChildren

         final static Integer countChildren(Drawable $self)

        Returns a count of this drawable's children, including children of children.

        Since:

        1.0.1

      • afterParentInit

         final static <S extends Drawable> S afterParentInit(S $self, Integer depth, Function1<S, Unit> handler)

        Add an event handler to this drawable's parent, and (optionally) it's parent's parent (depth).

        This is used to run functions that may move or resize this drawable, as if they were ran under this Event.Lifetime.PostInit they would be overwritten by the positioning logic.

      • locate

         final static <S extends Drawable> S locate(Drawable $self, String id)

        Locate a drawable by its name.

        This method is recursive, meaning it will search through all children of this drawable.

        Parameters:
        id - the name of the drawable to locate.
        Returns:

        the drawable with the given name, or null if it was not found.

        Since:

        1.1.72

      • animateBy

         final static Unit animateBy(Drawable $self, Vec2 at, Vec2 size, Double rotation, Float scaleX, Float scaleY, Double skewX, Double skewY, PolyColor color, Animation animation)

        Bulk add method for all the builtin drawable operations in PolyUI.

        The default values of this method are all zeroes, meaning that nothing is done.

        This is the "by" version of this method, meaning that each value is added to the current one of this drawable. See the animateTo method for the "to" equivalent, which sets each value to the provided one.

      • animateTo

         final static Unit animateTo(Drawable $self, Float tx, Float ty, Vec2 size, Double rotation, Double skewX, Double skewY, Float scaleX, Float scaleY, PolyColor color, Animation animation)

        Bulk add method for all the builtin drawable operations in PolyUI.

        The default values of this method are all the current ones of this drawable, meaning that nothing is done.

        This is the "to" version of this method, meaning that each value is set to the provided one. See the animateBy method for the "by" equivalent, which adds each value to the current one of this drawable.