mirror of https://github.com/axmolengine/axmol.git
Merge pull request #13315 from ZhangMenghe/v3-touchInter
[ci skip]Add testcase to issue3053
This commit is contained in:
commit
38b1da2c06
|
@ -283,3 +283,55 @@ var UIListViewTest_Horizontal = UIMainLayer.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
var UIListViewTest_TouchIntercept = UIMainLayer.extend({
|
||||
init: function () {
|
||||
if(this._super()) {
|
||||
var widgetSize = this._widget.getContentSize();
|
||||
var background = this._widget.getChildByName("background_Panel");
|
||||
var backgroundSize = background.getContentSize();
|
||||
|
||||
this._topDisplayLabel.setString("TouchIntercept");
|
||||
this._topDisplayLabel.x = widgetSize.width / 2.0;
|
||||
this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5;
|
||||
this._bottomDisplayLabel.setString("ListView Disable Touch");
|
||||
this._bottomDisplayLabel.x = widgetSize.width / 2;
|
||||
this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3;
|
||||
|
||||
// Create the list view
|
||||
var listView = new ccui.ListView();
|
||||
// set list view ex direction
|
||||
listView.setDirection(ccui.ScrollView.DIR_NONE);
|
||||
listView.setBounceEnabled(true);
|
||||
listView.setTouchEnabled(false);
|
||||
listView.setBackGroundImage("ccs-res/cocosui/green_edit.png");
|
||||
listView.setBackGroundImageScale9Enabled(true);
|
||||
listView.setContentSize(cc.size(240, 130));
|
||||
listView.x = (widgetSize.width - backgroundSize.width) / 2 + (backgroundSize.width - listView.width) / 2;
|
||||
listView.y = (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - listView.height) / 2;
|
||||
this._mainNode.addChild(listView);
|
||||
|
||||
// create model
|
||||
var default_button = new ccui.Button();
|
||||
default_button.setName("Title Button");
|
||||
default_button.loadTextures("ccs-res/cocosui/backtotoppressed.png", "ccs-res/cocosui/backtotopnormal.png", "");
|
||||
|
||||
var default_item = new ccui.Layout();
|
||||
default_item.setTouchEnabled(true);
|
||||
default_item.setContentSize(default_button.getContentSize());
|
||||
default_item.width = listView.width;
|
||||
default_button.x = default_item.width / 2;
|
||||
default_button.y = default_item.height / 2;
|
||||
default_item.addChild(default_button);
|
||||
|
||||
// set model
|
||||
listView.setItemModel(default_item);
|
||||
listView.pushBackDefaultItem();
|
||||
listView.pushBackDefaultItem();
|
||||
listView.pushBackDefaultItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
|
@ -527,4 +527,54 @@ var UIPageViewDynamicAddAndRemoveTest = UIMainLayer.extend({
|
|||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var UIPageViewDisableTouchTest = UIMainLayer.extend({
|
||||
init: function () {
|
||||
if(this._super()){
|
||||
var widgetSize = this._widget.getContentSize();
|
||||
|
||||
this._topDisplayLabel.setString("PageView disable touch");
|
||||
this._topDisplayLabel.x = widgetSize.width / 2.0;
|
||||
this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5;
|
||||
|
||||
this._bottomDisplayLabel.setString("PageView");
|
||||
this._bottomDisplayLabel.x = widgetSize.width / 2;
|
||||
this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3;
|
||||
|
||||
var background = this._widget.getChildByName("background_Panel");
|
||||
var backgroundSize = background.getContentSize();
|
||||
|
||||
var pageView = new ccui.PageView();
|
||||
pageView.setContentSize(cc.size(240, 130));
|
||||
pageView.x = (widgetSize.width - backgroundSize.width) / 2 + (backgroundSize.width - pageView.width) / 2;
|
||||
pageView.y = (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - pageView.height) / 2;
|
||||
pageView.setTouchEnabled(false);
|
||||
pageView.removeAllPages();
|
||||
|
||||
var pageCount = 4;
|
||||
for(var i = 0; i < pageCount; i++){
|
||||
var layout = new ccui.Layout();
|
||||
layout.setContentSize(cc.size(240, 130));
|
||||
|
||||
var imageView = new ccui.ImageView();
|
||||
imageView.setScale9Enabled(true);
|
||||
imageView.loadTexture("ccs-res/cocosui/scrollviewbg.png");
|
||||
imageView.setContentSize(cc.size(240, 130));
|
||||
imageView.x = layout.getContentSize().width / 2;
|
||||
imageView.y = layout.getContentSize().height / 2;
|
||||
layout.addChild(imageView);
|
||||
var pageNumber = i+1;
|
||||
var label = new ccui.Text("page" + pageNumber, "Marker Felt",30);
|
||||
label.setColor(cc.color(192, 192, 192));
|
||||
label.setPosition(cc.p(layout.getContentSize().width / 2, layout.getContentSize().height / 2));
|
||||
layout.addChild(label);
|
||||
|
||||
pageView.insertPage(layout, i);
|
||||
}
|
||||
this._mainNode.addChild(pageView);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
|
@ -465,6 +465,12 @@
|
|||
func: function () {
|
||||
return new UIScrollViewRotated();
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "UIScrollViewDisableTest",
|
||||
func: function () {
|
||||
return new UIScrollViewDisableTest();
|
||||
}
|
||||
}
|
||||
],
|
||||
"UIPageView": [
|
||||
|
@ -497,6 +503,12 @@
|
|||
func: function () {
|
||||
return new UIPageViewDynamicAddAndRemoveTest();
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "UIPageViewDisableTouchTest",
|
||||
func: function () {
|
||||
return new UIPageViewDisableTouchTest();
|
||||
}
|
||||
}
|
||||
],
|
||||
"UIListView": [
|
||||
|
@ -511,6 +523,12 @@
|
|||
func: function () {
|
||||
return new UIListViewTest_Horizontal();
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"UIListViewTest_TouchIntercept ",
|
||||
func: function() {
|
||||
return new UIListViewTest_TouchIntercept();
|
||||
}
|
||||
}
|
||||
],
|
||||
"UIWidget": [
|
||||
|
|
|
@ -412,4 +412,70 @@ var UIScrollViewRotated = UIMainLayer.extend({
|
|||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var UIScrollViewDisableTest = UIMainLayer.extend({
|
||||
init: function () {
|
||||
if (this._super()){
|
||||
var widgetSize = this._widget.getContentSize();
|
||||
|
||||
this._topDisplayLabel.setString("ScrollView Disable Test");
|
||||
this._topDisplayLabel.x = widgetSize.width / 2.0;
|
||||
this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5;
|
||||
|
||||
this._bottomDisplayLabel.setString("ScrollView vertical");
|
||||
this._bottomDisplayLabel.x = widgetSize.width / 2;
|
||||
this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3;
|
||||
|
||||
var background = this._widget.getChildByName("background_Panel");
|
||||
var backgroundSize = background.getContentSize();
|
||||
|
||||
var scrollView = new ccui.ScrollView();
|
||||
scrollView.setContentSize(cc.size(280, 150));
|
||||
scrollView.x = (widgetSize.width - backgroundSize.width) / 2 + (backgroundSize.width - scrollView.width) / 2;
|
||||
scrollView.y = (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - scrollView.height) / 2;
|
||||
scrollView.setTouchEnabled(false);
|
||||
|
||||
this._mainNode.addChild(scrollView);
|
||||
|
||||
var imageView = new ccui.ImageView();
|
||||
imageView.loadTexture("ccs-res/cocosui/ccicon.png");
|
||||
|
||||
var innerWidth = scrollView.width;
|
||||
var innerHeight = scrollView.height + imageView.height;
|
||||
|
||||
scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight));
|
||||
|
||||
var button = new ccui.Button();
|
||||
button.setTouchEnabled(true);
|
||||
button.loadTextures("ccs-res/cocosui/animationbuttonnormal.png", "ccs-res/cocosui/animationbuttonpressed.png", "");
|
||||
button.x = innerWidth / 2;
|
||||
button.y = scrollView.getInnerContainerSize().height - button.height / 2;
|
||||
scrollView.addChild(button);
|
||||
|
||||
var textButton = new ccui.Button();
|
||||
textButton.setTouchEnabled(true);
|
||||
textButton.loadTextures("ccs-res/cocosui/backtotopnormal.png", "ccs-res/cocosui/backtotoppressed.png", "");
|
||||
textButton.setTitleText("Text Button");
|
||||
textButton.x = innerWidth / 2;
|
||||
textButton.y = button.getBottomBoundary() - button.height;
|
||||
scrollView.addChild(textButton);
|
||||
|
||||
var button_scale9 = new ccui.Button();
|
||||
button_scale9.setTouchEnabled(true);
|
||||
button_scale9.setScale9Enabled(true);
|
||||
button_scale9.loadTextures("ccs-res/cocosui/button.png", "ccs-res/cocosui/buttonHighlighted.png", "");
|
||||
button_scale9.width = 100;
|
||||
button_scale9.height = 32;
|
||||
button_scale9.x = innerWidth / 2;
|
||||
button_scale9.y = textButton.getBottomBoundary() - textButton.height;
|
||||
scrollView.addChild(button_scale9);
|
||||
|
||||
imageView.setPosition(cc.p(innerWidth/2, imageView.getContentSize().height/2));
|
||||
scrollView.addChild(imageView);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue