Expandable Buttons
ဒီနမူနာ program ကေတာ့ Button ေတြထဲက တခုကို ႏွိပ္လိုက္ရင္ အဲဒီ button နဲ႔ ဆိုင္တဲ့ information ေတြကို button ေအာက္တည့္တည့္မွာ label တခု ၾကားထိုးၿပီး ေဖာ္ျပတဲ့နည္း ျဖစ္ပါတယ္။
===========
Views Panel
===========
AddPanel("pnl1",0,0,100%x,100%y,"")
AddscrollView("scr1", 0,0,100%x,100%y ,"pnl1")
getPanel("scr1","pnl2")
AddButton("btn1",0,0,100%x,25%y,"pnl2")
SetText("btn1","Button 1")
AddButton("btn2", 0,25%y,100%x,25%y,"pnl2")
SetText("btn2","Button 2")
AddButton("btn3", 0,50%y,100%x,25%y,"pnl2")
SetText("btn3","Button 3")
AddButton("btn4", 0,75%y,100%x,25%y,"pnl2")
SetText("btn4","Button 4")
# Info Label to Show when Button clicked
AddLabel("lbl1", 0,0,100%x,25%y,"pnl2")
SetVisible("lbl1",false )
# initial Settings
Setheight("pnl2",100%y)
stateOpen=0
# informations
info1="info when butt 1 is pressed"
info2="info when butt 2 is pressed"
info3="info when butt 3 is pressed"
info4="info when butt 4 is pressed"
===========
Events Panel
===========
Sub Activity_Pause(UserClosed)
End Sub
Sub Activity_Resume
End Sub
# ###################
Sub Button_Click(Who)
select who
case "btn1"
if stateOpen=1 then
stateOpen=0
displayInfo(0)
else
stateOpen=1
displayInfo(1)
end if
case "btn2"
if stateOpen=2 then
stateOpen=0
displayInfo(0)
else
stateOpen=2
displayInfo(2)
end if
case "btn3"
if stateOpen=3 then
stateOpen=0
displayInfo(0)
else
stateOpen=3
displayInfo(3)
end if
case "btn4"
if stateOpen=4 then
stateOpen=0
displayInfo(0)
else
stateOpen=4
displayInfo(4)
end if
end select
End Sub
# ###############
sub displayInfo(n)
select n
case 0
Setheight("pnl2",100%y)
Settop("btn2",25%y)
Settop("btn3",50%y)
Settop("btn4",75%y)
SetVisible("lbl1",false)
case 1
Setheight("pnl2",125%y)
Settop("lbl1",25%y)
Settop("btn2",50%y)
Settop("btn3",75%y)
Settop("btn4",100%y)
SetVisible("lbl1",true)
SetText("lbl1",info1)
case 2
Setheight("pnl2",125%y)
Settop("lbl1",50%y)
Settop("btn2",25%y)
Settop("btn3",75%y)
Settop("btn4",100%y)
SetVisible("lbl1",true)
SetText("lbl1",info2)
case 3
Setheight("pnl2",125%y)
Settop("lbl1",75%y)
Settop("btn2",25%y)
Settop("btn3",50%y)
Settop("btn4",100%y)
SetVisible("lbl1",true)
SetText("lbl1",info3)
case 4
Setheight("pnl2",125%y)
Settop("lbl1",100%y)
Settop("btn2",25%y)
Settop("btn3",50%y)
Settop("btn4",75%y)
SetVisible("lbl1",true)
SetText("lbl1",info4)
end select
end sub
# ##########
No comments:
Post a Comment