Skip to content

Hybrid RadioGroup #149

@Al4He6

Description

@Al4He6

2.79.1 Hybrid RadioGroup

setColor and setColorByIndex seem to have no effect

Has setTextSizeIndex
other methods are ByIndex

var main,tgt,lay2,lay1
var  list = [ "radio1", "radio2", "radio3" ]
export class Main extends App {
        onStart() {
           main = ui.addLayout( "main", "Linear", "left,Top", 1, 1 )
           
           var sel2 = ui.addSelect(main,"Primary,Secondary,Default","radio,small,dense",0.9)
           sel2.label = "Colour"
           var sel1 = ui.addSelect(main,"Small,Medium","radio,small,dense",0.9)
           sel1.label = "Size"
           var sel3 = ui.addSelect(main,"Horizontal,Vertical","radio,small,dense",0.9)
           sel3.label = "Orientation"
           var sel4 = ui.addSelect(main,"Left,Right","radio,small,dense",0.9)
           sel4.label = "Align"
           var sel5 = ui.addSelect(main,"Elevated,Outlined,Square","radio,small,dense",0.9)
           sel5.label = "Variant"
           var sel6 = ui.addSelect(main,"Required","multiple,small,dense",0.9)
           sel6.label = "Util"

            var btn2 = ui.addButton(main,"Create Radio Group","small,secondary")
            btn2.setOnTouch( function() {
            if (typeof tgt !="undefined") tgt.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
            if (sel6.value != "") opt += ","+sel6.value.toString()
            tgt = ui.addRadioGroup( lay1, list, opt, 1 )
            tgt.setOnTouch(function (a,b,c,d) {
                    alert ("TOUCH\n"+a+"\n"+b+"\n"+JSON.stringify(c)+"\n"+JSON.stringify(d))
                    alert("value="+this.value)
                    alert(this.checkedIcon)
            }) // ontouch tgt      
            lay2.show()   
          }) // ontouch btn2

            lay1 = ui.addLayout(main,"Linear","top,left",0.95)
            lay2 = ui.addLayout(main,"Linear","top,left,scrolly",0.95,0.37)
            lay2.hide()
            bt('alert(tgt.el.innerHTML) ')
            bt('tgt.backColor = "blue" ')
            bt('tgt.textColor = "yellow" ')
            bt('tgt.itemColor = "green" ')
            bt('tgt.textSize = "2rem" ')
            bt('tgt.textWeight = "thin" ')
            bt('tgt.label = "Radio Group" ')
            bt('tgt.icon="home" ')
            bt('tgt.checkedIcon="more" ')
            bt('tgt.radioPosition="left" ')
            bt('tgt.radioPosition="right" ')
            bt('tgt.radioSize="small" ')
            bt('tgt.radioSize="medium" ')
            bt('tgt.setList(list) ')
            bt('alert(tgt.popItem()) ')
            bt('alert(tgt.shiftItem()) ')
            bt('tgt.addItem("radio5") ')
            bt('tgt.setItem("radio1","setItem") ')
            bt('tgt.setItemByName("radio1","setItemByName") ')
            bt('tgt.setItemByIndex(2,"setItemByIndex") ')
            bt('tgt.setEnabled("radio2",!tgt.getEnabled("radio2")) ')
            bt('tgt.setEnabledByIndex(2,!tgt.getEnabledByIndex(2)) ')
            bt('tgt.removeItemByName("radio1") ')
            bt('tgt.removeItemByIndex(1) ')
            bt('tgt.disabled=!tgt.disabled')
            bt('tgt.setEnabled("radio2",!tgt.getEnabled("radio2")) ')
            bt('tgt.setEnabledByIndex(2,!tgt.getEnabledByIndex(2)) ')
            bt('tgt.value=2' )
            bt('tgt.selectedIcon="radio2" ')
            bt('tgt.setIconByIndex(1,"filter_4") ')
            bt('tgt.setIcon("radio3","filter_3") ')
            bt('tgt.setCheckedIconByIndex(1,"filter_5") ')
            bt('tgt.setCheckedIcon("radio3","filter_6") ')
            bt('tgt.setItemColorByIndex(1,"red") ')
            bt('tgt.setItemColor("radio3","blue") ')
            bt('tgt.setColorByIndex(1,"primary") // ? ')
            bt('tgt.setColor("radio3","secondary") // ? ')
            bt('tgt.setRadioSizeByIndex(1,"small") ')
            bt('tgt.setRadioSize("radio3","small") ')
            bt('tgt.setTextColorByIndex(1,"cyan") ')
            bt('tgt.setTextColor("radio3","green") ')
            bt('tgt.setTextSizeIndex(1,"2rem") // NOT BY ')
            bt('tgt.setTextSize("radio3","2rem") ')
            bt('tgt.setTextWeightByIndex(1,"thin") ')
            bt('tgt.setTextWeight("radio3","thin") ')
            bt('tgt.hide() ')
            bt('tgt.show() ')
         
        } // onstart
 } // class
 function bt (str) {
   var temp = ui.addText(lay2,str,"keepcase,default,large",1) 
   temp.setMargins(10,5,0,0,"px")
   temp.backColor="cyan"
   temp.setOnTouch(touched)
 } // bt
 function touched() {
   eval(this.text)
 } // touched

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