基础容器的常用接口

设置是否响应触摸事件。
setTouchEnabled (bool enabled)

设置用于识别节点的名字。
setName (const std::string &name)

设置用于识别节点的标记。
setTag (int tag)

设置控件在OpenGL坐标系中的百分比位置(x,y)
setPositionPercent

设置控件的位置类型
setPositionType (PositionType type)

检查一个位置点是否在父节点区域内
clippingParentAreaContainPoint (const Vec2 &pt)

设置控件的尺寸
setContentSize (const Size &contentSize) override

设置控件的百分比尺寸
setSizePercent (const Vec2 &percent)

改变控件的尺寸类型。
setSizeType (SizeType type)

设置控件的尺寸
setSize (const Size &size)

給控件设置一个布局参数(LayoutParameter)
setLayoutParameter (LayoutParameter *parameter)

设置控件是否吞噬触摸事件
setSwallowTouches (bool swallow)

切换控件是否拥有焦点。
setFocused (bool focus)

允许控件的触摸事件向上传播到父节点,设置为false会阻止向上传播。
setPropagateTouchEvents (bool isPropagate)

设置动作的标签
setActionTag (int tag)

获取当前拥有焦点的控件。不管对什么控件对象调用这个方法,它将返回当前拥有焦点的控件。
getCurrentFocusedWidget (bool isWidget)

设置回调函数的名称。
setCallbackName (const std::string &callbackName)

设置回调函数类型
setCallbackType (const std::string &callbackType)

设置是否启用布局组件。
setLayoutComponentEnabled (bool enable)

设置layout的背景图像。
setBackGroundImage(const std::string & fileName, TextureResType texType = TextureResType::LOCAL)

设置背景的颜色类型
setBackGroundColorType (BackGroundColorType type)

设置layout的背景颜色 仅当颜色类型为BackGroundColorType::SOLID的时候,才会影响Layout
setBackGroundColor(const Color3B & color)

为布局设置开始和结束的背景颜色。 该设置只当布局的颜色类型是BackGroundColorType::GRADIENT时生效
setBackGroundColor(const Color3B & startColor, const Color3B & endColor)

设置布局的背景颜色渐变方向。 该设置只当布局的颜色类型是BackGroundColorType::GRADIENT时生效
setBackGroundColorVector(const Vec2 & vector)

设置布局的背景颜色不透明度。
setBackGroundColorOpacity(GLubyte opacity)

设置背景图像的不透明度。
setBackGroundImageOpacity(GLubyte opacity)

切换布局剪裁。 如果你需要裁剪,你需要传递true给这个函数。
setClippingEnabled(bool enabled)

改变layout的剪裁类型。 在默认情况下,剪切类型是“ClippingType:STENCIL”。
setClippingType (ClippingType type)

改变布局类型
setLayoutType(Type type)

设置一个用户自定义数据的指针。
setUserData (void *userData)

原文地址:https://www.cnblogs.com/damowang/p/5303540.html