Skip to content

Hybrid Tabs #110

Closed
Closed

Description

@Al4He6

V033
For Tabs some methods don't seem to be defined
setText, setItem, setItemByIndex, removeItem
I get an error from setIcon
Not sure if setting centred property has any effect.

var main,lay1, lay2, tabs
var list = ["Tab 1","Tab 2","Tab 3"]
var listicons = [
            ["favorite", "Favorites"],
            ["bluetooth", "Bluetooth"],
            ["wifi", "Connection"]
        ]
class Main extends App {
    onStart() {
        main = ui.addLayout( "main", "Linear", "top,left")
        var sel1 = ui.addSelect(main,"Swipable","radio,small",0.9)
        sel1.label = "Swipe"
        var sel2 = ui.addSelect(main,"Primary,Secondary,Inherit,Transparent,Default","small,radio",0.9)
        sel2.label = "Theme"
        var sel3 = ui.addSelect(main,"Standard,Scrollable,FULLWIDTH","radio,small",0.9)
        sel3.label = "Variant"
        var sel4 = ui.addSelect(main,"Linear,Absolute","radio,small",0.9)
        sel4.label = "Layout"
        var sel5 = ui.addSelect(main,"Icon,Center,Paper,Keepcase","multiple,small",0.9)
        sel5.label = "Utils"
        var but = ui.addButton(main,"Create Tabs","small,keepcase,primary")
        but.setOnTouch( function() {
            if (typeof tabs !="undefined") tabs.destroy()
            var opt = ""
            if (sel1.value != "") opt = sel1.value
            if (sel2.value != "") opt += ","+sel2.value
            if (sel3.value != "") opt += ","+sel3.value
            if (sel4.value != "") opt += ","+sel4.value
            if (sel5.value != "") opt += ","+sel5.value
            var str = list
            if (sel5.value.includes("Icon")) str= listicons
            tabs = ui.addTabs(lay1, str,opt, 0.7)
            tabs.setOnTouch(function(tab,index,pos) {ui.showPopup(tab+" - "+index+" - "+JSON.stringify(pos))})
            tabs.setOnChange(function(tab,index) {ui.showPopup(tab+" - "+index)})
            var tab1 = tabs.getLayout(0)
            var btn1 = ui.addButton(tab1, "Button on Tab1", "Secondary,keepcase", 0.5)
            var btn2 = ui.addButton(tab1, "Button on Tab1", "Secondary,keepcase", 0.5)
            var tab2 = tabs.getLayout(1)
            var txt = ui.addText(tab2, "Text on Tab2", "Center", 1)
            var tab3 = tabs.getLayout(2)
            var ckb = ui.addCheckbox(tab3, "Checkbox on Tab3", "Secondary")
            lay2.show()
        } ) // ontouch
        lay1 = ui.addLayout(main,"Linear","top,left",0.9)
        lay2 = ui.addLayout(main,"Linear","top,left,scrolly",0.9,0.53)
        lay2.hide()
        btn('tabs.setTabs(list)')
        btn('tabs.setTabs(listicons)')
        btn('tabs.backColor="blue"')
        btn('tabs.textColor="yellow"')
        btn('tabs.iconColor="magenta"')
        btn('tabs.centered=true // effective?')
        btn('tabs.scrollButtonMode="auto"')
        btn('tabs.scrollButtonMode="on"')
        btn('tabs.scrollButtonMode="off"')
        btn('tabs.scrollButtonMode="desktop"')
        btn('tabs.setIndicatorStyle(0.9, 6, "red", 3)')
        btn('tabs.setTabPadding(50,0,50,0,"px")')
        btn('tabs.addTab("addTab")')        
        btn('tabs.setText("Bluetooth","setText") // not a fn')
        btn('tabs.setIcon("Connection","filter_5") // cannot set property')
        btn('tabs.setIcon(1,"filter_6") ')
        btn('tabs.setItem("Favorites","setItem","filter_4") // not a fn')
        btn('tabs.setItemByIndex(1,"setItemByIndex","filter_5") // not a fn)')
        btn('tabs.removeTab("Tab 1") // not a fn')
        btn('tabs.removeTabByName("Tab 1")')
        btn('tabs.removeTabByIndex(1)')
        btn('alert(tabs.popItem())')
        btn('alert(tabs.shiftItem())')

    } // onstart

} // class
function btn(txt) {
       var temp = ui.addButton(lay2, txt, "small,keepcase")
       temp.backColor="cyan"
       temp.setMargins(5,5,0,0,"px")
       temp.setOnTouch(doit)
} // btn
function doit() {
       eval(this.text)
}// doit

Activity

  1. enjine-io commented on Oct 9, 2026

    @enjine-io
    Collaborator

    Thanks, this is now Fixed in 2.81

    • setText, setItem, setItemByIndex and removeTab are all defined in 2.81.
    • setIcon, setText and setItem no longer give an error for a tab name that isn't in the list. (In your sample, "Connection" and "Bluetooth" only exist in the icon list, so they errored on the plain list.)
    • centered: the Standard option was being ignored on phone sized screens, where the Tabs always used FullWidth, and FullWidth tabs fill the whole width so there is nothing to centre. Standard now works, and centered (or the Center option) centres Standard tabs. tabs.variant = "Standard" works too; before it left the variant unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions