Animated Color LabelButton
အရင္တေခါက္က User interaction နဲ႔ button click လုပ္တဲ့အခါ color/image ထည့္ထားရင္ animation ရေအာင္ timer သံုးၿပီး ေရးျပခဲ့ပါတယ္။ အခုတခါေတာ့ ဒီထက္ပိုေကာင္းတဲ့ Label + activity_touch event ကိုသံုးၿပီး ေရးျပပါမယ္။
activity_touch(action,tx,ty) event မွာ action=0 က down, 1=up, နဲ႔ 2=drag ျဖစ္ပါတယ္။ tx နဲ႔ ty ကေတာ့ touch point ရဲ့ x နဲ႔ y တန္ဖိုးပါ။ tx နဲ႔ ty တန္ဖိုးေတြဟာ Label ရဲ့ အတိုင္းအတာ အတြင္းမွာ ရွိရင္ color ေျပာင္းျပၿပီး click တဲ့ ပံုစံမ်ိဳ း ျဖစ္ေအာင္ ေရးပါမယ္။
Views Panel
==========
AddPanel("pnl1",0,0,100%x,100%y,"")
AddLabel("lblbtn1",10%x,10%y,80%x,20%y,"pnl1")
SetColor( "lblbtn1",60,cyellow)
SetText("lblbtn1","Menu 1")
SetGravity("lblbtn1",17 )
x11=10%x
x12=90%x
y11=10%y
y12=30%y
AddLabel ("lblbtn2",10%x,40%y,80%x,20%y,"pnl1")
SetColor( "lblbtn2",60,cyellow)
SetText("lblbtn2","Menu 2")
SetGravity("lblbtn2",17 )
x21=10%x
x22=90%x
y21=40%y
y22=60%y
currentlblbtn=""
===========
Events Panel
===========
Sub Activity_Pause(UserClosed)
End Sub
Sub Activity_Resume
End Sub
sub activity_touch(action,tx,ty)
select action
case 0
if (tx>x11) then
if (tx<x12) then
if (ty>y11) then
if (ty<y12) then
SetColor("lblbtn1",60,cgreen)
invalidate("lblbtn1")
currentlblbtn="lblbtn1"
end if
end if
end if
end if
if (tx>x21) then
if (tx<x22) then
if (ty>y21) then
if (ty<y22) then
SetColor("lblbtn2",60,cgreen)
invalidate("lblbtn2")
currentlblbtn="lblbtn2"
end if
end if
end if
end if
case 1
SetColor(currentlblbtn,60,cyellow)
invalidate(currentlblbtn)
if currentlblbtn="lblbtn1" then
MsgBox("You choose Menu1","")
else if currentlblbtn ="lblbtn2" then
MsgBox("You choose Menu2","")
end if
end select
end sub
================
No comments:
Post a Comment