Can I pass the name
of the widget to the function
to create Tabs?
Something like
let widgetName = new Tab({
...
Why?
- I need to put many different
widgets inside of the each
tab
created, i.e.:.appendTo(tabCart)
Note: When I create a function createTextViews()
I assign a unique
id: txvName +(index)
(an array
is passed to createTextView()
, then a forEach
loop)
and can address each TextView
by id, which works great.
Sample Code: (works on /playground)
const {Tab, TabFolder, TextView, ui} = require('tabris')
let tabFolder = new TabFolder({
left: 0, top: 0, right: 0, bottom: 0
}).appendTo(ui.contentView)
createTab('tabCart', 'Cart')
createTab('tabPay', 'Pay')
createTab('tabStats', 'Stats')
function createTab (widgetName, title) {
// let widgetName = new Tab({ //fails, can't assign twice, wrong type anyways
let tab = new Tab({
title: title
}).appendTo(tabFolder)
new TextView({
centerX: 0, centerY: 0,
text: 'Content of Tab ' + title
}).appendTo(tab)
}