Class ccui.Widget

Class Summary
Constructor Attributes Constructor Name and Description
 
Base class for ccui.Widget

Method Summary

Class Detail

ccui.Widget()
Base class for ccui.Widget

Field Detail

{Number} actionTag
- The action tag of the widget
{Boolean} bright
- Indicate whether the widget is bright
{Boolean} enabled
- Indicate whether the widget is enabled
{Boolean} focused
- Indicate whether the widget is focused
{Number} heightPercent
- Height in percentage of parent height
{String} name
- The name of the widget
{ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} sizeType
- The size type of the widget
{Boolean} touchEnabled
- Indicate whether touch events are enabled
{Boolean} updateEnabled
- Indicate whether the update function is scheduled
{ccui.Widget} widgetParent
- <@readonly> The direct parent when it's a widget also, otherwise equals null
{ccui.Widget.TYPE_WIDGET|ccui.Widget.TYPE_CONTAINER} widgetType
- <@readonly> The type of the widget
{Number} widthPercent
- Width in percentage of parent width
{Number} xPercent
- Position x in percentage of width
{Number} yPercent
- Position y in percentage of height

Method Detail

  • addChild(widget, zOrder, tag)
    Adds a child to the container.
    Parameters:
    {ccui.Widget} widget
    {Number} zOrder
    {Number} tag
  • addNode(node, zOrder, tag)
    add node for widget
    Parameters:
    {cc.Node} node
    {Number} zOrder
    {Number} tag
  • addTouchEventListener(selector, target)
    Sets the touch event target/selector of the menu item
    Parameters:
    {Function} selector
    {Object} target
  • checkChildInfo(handleState, sender, touchPoint)
    Sends the touch event to widget's parent
    Parameters:
    {number} handleState
    {ccui.Widget} sender
    {cc.Point} touchPoint
  • {Boolean} clippingParentAreaContainPoint(pt)
    Checks a point if in parent's area.
    Parameters:
    {cc.Point} pt
    Returns:
    {Boolean}
  • <static> {ccui.Widget} ccui.Widget.create()
    allocates and initializes a UIWidget.
    // example
    var uiWidget = ccui.Widget.create();
    Returns:
    {ccui.Widget}
  • didNotSelectSelf()
    A call back function when widget lost of focus.
  • {number} getBottomInParent()
    Gets the bottom boundary position of this widget.
    Returns:
    {number}
  • {ccui.Widget} getChildByName(name)
    Gets a child from the container with its name
    Parameters:
    {string} name
    Returns:
    {ccui.Widget}
  • {ccui.Widget} getChildByTag(tag)
    Parameters:
    tag
    Returns:
    {ccui.Widget}
  • {Array} getChildren()
    Return an array of children
    Returns:
    {Array}
  • {Number} getChildrenCount()
    get the count of children
    Returns:
    {Number}
  • {cc.Color} getColor()
    Get color
    Returns:
    {cc.Color}
  • {cc.Size} getContentSize()
    Gets the content size of widget.
    Returns:
    {cc.Size}
  • {cc.Size} getCustomSize()
    Get custom size
    Returns:
    {cc.Size}
  • {string} getDescription()
    Returns the "class name" of widget.
    Returns:
    {string}
  • {ccui.LayoutParameter} getLayoutParameter(type)
    Gets layout parameter
    Parameters:
    {ccui.LayoutParameter.NONE|ccui.LayoutParameter.LINEAR|ccui.LayoutParameter.RELATIVE} type
    Returns:
    {ccui.LayoutParameter}
  • {number} getLeftInParent()
    Gets the left boundary position of this widget.
    Returns:
    {number}
  • {string} getName()
    Gets the name of widget
    Returns:
    {string}
  • {cc.Node} getNodeByTag(tag)
    get node by tag
    Parameters:
    {Number} tag
    Returns:
    {cc.Node}
  • {Array} getNodes()
    get all node
    Returns:
    {Array}
  • {Number} getOpacity()
    Get opacity
    Returns:
    {Number}
  • {cc.Point} getPositionPercent()
    Gets the percent (x,y) of the widget
    Returns:
    {cc.Point}
  • {cc.pPositionType} getPositionType()
    Gets the position type of the widget
    Returns:
    {cc.pPositionType}
  • {number} getRightInParent()
    Gets the right boundary position of this widget.
    Returns:
    {number}
  • {cc.Size} getSize()
    Returns size of widget
    Returns:
    {cc.Size}
  • {cc.Point} getSizePercent()
    Returns size percent of widget
    Returns:
    {cc.Point}
  • {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} getSizeType()
    Gets the size type of widget.
    Returns:
    {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT}
  • {number} getTopInParent()
    Gets the top boundary position of this widget.
    Returns:
    {number}
  • {cc.Point} getTouchEndPos()
    Gets touch end position
    Returns:
    {cc.Point}
  • {cc.Point} getTouchMovePos()
    Gets touch move position
    Returns:
    {cc.Point}
  • {cc.Point} getTouchStartPos()
    Gets touch start position
    Returns:
    {cc.Point}
  • {cc.Node} getVirtualRenderer()
    Gets the Virtual Renderer of widget.
    Returns:
    {cc.Node}
  • {ccui.Widget.TYPE_WIDGET|ccui.Widget.TYPE_CONTAINER} getWidgetType()
    get widget type
    Returns:
    {ccui.Widget.TYPE_WIDGET|ccui.Widget.TYPE_CONTAINER}
  • {cc.Point} getWorldPosition()
    Gets world position of widget.
    Returns:
    {cc.Point}
  • {boolean} hitTest(pt)
    Checks a point if is in widget's space
    Parameters:
    {cc.Point} pt
    Returns:
    {boolean}
  • ignoreContentAdaptWithSize(ignore)
    Ignore the widget size
    Parameters:
    {Boolean} ignore
  • {boolean} init()
    initializes state of widget.
    Returns:
    {boolean}
  • initRenderer()
    initializes renderer of widget.
  • {boolean} isBright()
    Determines if the widget is bright
    Returns:
    {boolean}
  • {boolean} isEnabled()
    Determines if the widget is enabled
    Returns:
    {boolean}
  • {Boolean} isFlippedX()
    Get flipped x
    Returns:
    {Boolean}
  • {Boolean} isFlippedY()
    Get flipped y
    Returns:
    {Boolean}
  • {boolean} isFocused()
    Determines if the widget is on focused
    Returns:
    {boolean}
  • {boolean} isIgnoreContentAdaptWithSize()
    Gets the widget if is ignore it's size.
    Returns:
    {boolean}
  • {boolean} isTouchEnabled()
    To set the bright style of widget.
    Returns:
    {boolean}
  • {boolean} isUpdateEnabled()
    is the "update" method scheduled.
    Returns:
    {boolean}
  • onPressStateChangedToDisabled()
    call back function called widget's state changed to dark.
  • onPressStateChangedToNormal()
    call back function called widget's state changed to normal.
  • onPressStateChangedToPressed()
    call back function called widget's state changed to selected.
  • onSizeChanged()
    call back function called when size changed.
  • onTouchCancelled(touchPoint)
    A call back function called when widget is selected, and on touch canceled.
    Parameters:
    {cc.Point} touchPoint
  • onTouchLongClicked(touchPoint)
    A call back function called when widget is selected, and on touch long clicked.
    Parameters:
    {cc.Point} touchPoint
  • removeAllChildren(cleanup)
    Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter.
    Parameters:
    cleanup
  • removeAllNodes()
    remove all node
  • removeChild(widget, cleanup)
    remove child
    Parameters:
    {ccui.Widget} widget
    {Boolean} cleanup
  • removeNode(node, cleanup)
    remove node
    Parameters:
    {cc.Node} node
    {Boolean} cleanup
  • removeNodeByTag(tag, cleanup)
    remove node by tag
    Parameters:
    {Number} tag
    {Boolean} cleanup
  • setBrightStyle(style)
    To set the bright style of widget.
    Parameters:
    {ccui.Widget.BRIGHT_STYLE_NONE|ccui.Widget.BRIGHT_STYLE_NORMAL|ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT} style
  • setColor(color)
    Set color
    Parameters:
    {cc.Color} color
  • setEnabled(enabled)
    Set enabled renderer
    Parameters:
    {Boolean} enabled
  • setFlippedX(flipX)
    Set flipped x
    Parameters:
    {Boolean} flipX
  • setFlippedY(flipY)
    Set flipped y
    Parameters:
    {Boolean} flipY
  • setFocused(fucos)
    Sets whether the widget is on focused The default value is false, a widget is default to not on focused
    Parameters:
    {boolean} fucos
  • setLayoutParameter(parameter)
    Sets layout parameter
    Parameters:
    {ccui.LayoutParameter} parameter
  • setName(name)
    Sets the name of widget
    Parameters:
    {String} name
  • setOpacity(opacity)
    Set opacity
    Parameters:
    {Number} opacity
  • setPosition(pos, posY)
    Changes the position (x,y) of the widget .
    Parameters:
    {cc.Point||Number} pos
    {Number} posY
  • setPositionPercent(percent)
    Changes the position (x,y) of the widget
    Parameters:
    {cc.Point} percent
  • setPositionType(type)
    Changes the position type of the widget
    Parameters:
    {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} type
  • setSize(size)
    Changes the size that is widget's size
    Parameters:
    {cc.Size} size
  • setSizePercent(percent)
    Changes the percent that is widget's percent size
    Parameters:
    {cc.Point} percent
  • setSizeType(type)
    TEXTURE_RES_TYPE Changes the size type of widget.
    Parameters:
    {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} type
  • setTouchEnabled(enable)
    Sets whether the widget is touch enabled
    Parameters:
    enable
  • setUpdateEnabled(enable)
    Schedules the "update" method.
    Parameters:
    enable
  • updateSizeAndPosition()
    update size and position