-
Notifications
You must be signed in to change notification settings - Fork 421
CAButton
Button class that is mainly used to receive user’s click operation thereby triggering particular event.
CAControl
Access modifier |
Attribute name |
Description |
public |
BackGroundView |
background view |
public |
Image |
images that different status displays |
public |
Type |
button type |
public |
Title |
button title |
public |
ImageColor |
image color |
public |
TitleColor |
title color |
public |
TitleFontName |
title font |
Access modifier |
Method name |
Description |
public |
setControlState |
set button’s status |
public |
isTextTagEqual |
judge text tag is equal or not |
public |
interruptTouchState |
interrupt button call-back event |
BackGroundView
Type: CAView*
Descripiton: background view in different statuses of button
Image
Type: CAImage*
Descripiton: image in different statuses of button, does not support 9 rectangle girds.
Type
Type: CAButtonType
Descripiton: button type, it’s an enumeration type.
typedef enum
{
CAButtonTypeCustom = 0,
CAButtonTypeSquareRect,
CAButtonTypeRoundedRect,
} CAButtonType;
Here we have three button types. There is nothing obvious effect after you create button in first type, it needs you to manually set; second button style adds rectangular border by default for created button; third button style adds rounded border by default for created button.
CAButtonTypeCustom Example:
CAButton* btn = CAButton: : create(CAButtonTypeCustom);
btn->setTitleForState(CAControlStateAll,"Hello");
btn->setFrame(CCRect(winRect. size. width*0. 5, winRect. size. height*0. 5, _px(100), _px(50)));
this->getView()->addSubview(btn);
CAButtonTypeSquareRect Example:
CAButton* btn = CAButton: : create(CAButtonTypeSquareRect);
btn->setTitleForState(CAControlStateAll,"Hello");
btn->setFrame(CCRect(winRect. size. width*0. 5, winRect. size. height*0. 5, _px(100), _px(50)));
this->getView()->addSubview(btn);
CAButtonTypeRoundedRect Example:
CAButton* btn = CAButton: : create(CAButtonTypeRoundedRect);
btn->setTitleForState(CAControlStateAll,"Hello");
btn->setFrame(CCRect(winRect. size. width*0. 5, winRect. size. height*0. 5, _px(100), _px(50)));
this->getView()->addSubview(btn);
Title
Type: string
Descripiton: It’s able to set button’s displayed title in different statuses.
ImageColor
Type: CAColor4B
Descripiton: button’s image color
TitleColor
Type: CAColor4B
Descripiton: color of button’s displayed title
TitleFontName
Type: string
Descripiton: title font
void setControlState(CAControlState var)
Return value: void
Parameter:
Type |
Parameter name |
Description |
CAControlState |
var |
button status |
bool isTextTagEqual(const char text)*
Return value: bool
Parameter:
Type |
Parameter name |
Description |
char* |
text |
designated text |
void interruptTouchState()
Return value: void
Descripiton: interrupt touch event, interrupt touch response according to different conditions.