Scrollable view (with touch disabled): buttons inside won't fire
Hi people,
So I have a scrollable view, which I dynamically add views to. Inside these views, I have a button that should slide the view to the left or to the right.
Now what seems to be odd is, whenever I have the touchEnabled property of the Scrollable view instance, set to false, my buttons inside the dynamically created views are not clickable.
With touchEnabled set to true, the buttons are clickable, but the doClick function does somehow not fire off the alert box.
Here's a stripped down version of my code:
var scrollView = Titanium.UI.createScrollableView({
currentPage:1,
touchEnabled: false,
showPagingControl: false
});
function doClick(e) {
var btn = e.source;
alert(" -- clicked button: " + btn);
};
for ... {
var newView = Ti.UI.createView();
var right = Titanium.UI.createButton({
image:'ui/right.png',
click: doClick,
left: 10,
width: 20
});
newView.add(right);
scrollView.addView(newView);
}
Any help would be appreciated!
2 Answers
-
I think the views overlap eachother and thats why the buttons can't fire.
Try adding "backgroundColor" to see which view overlaps the other. -
I don't think you can add an event listener to a control in the constructor/factory function (if you can, it's not documented anywhere I see). I put together the following app.js example which shows how to do pretty much exactly what you're trying to do, except I omit
touchEnabled:false
which causes the entire visible view in the scrollable view to be unresponsive.