buttons on android app
Posted: Sun May 05, 2019 8:35 pm
hello friends, am new user of spiderbasic. when i create an android app with more than one button, the whole buttons reffer to the last callback in the code. sample code
both buttons, plus and moins reffer to mns() procedure. i want plus button to get pls() callback and moins button to get mns() callback. thank you a lot.
Code: Select all
Declare pls()
Declare mns()
CloseDebugOutput()
Procedure pls()
v1 = Val(GetGadgetText(1))
v2 = Val(GetGadgetText(3))
v3.f = v1+v2
SetGadgetText(1, StrF(v3,2))
SetActiveGadget(1)
EndProcedure
Procedure mns()
v1 = Val(GetGadgetText(1))
v2 = Val(GetGadgetText(3))
v3.f = v1-v2
SetGadgetText(1, StrF(v3,2))
SetActiveGadget(1)
EndProcedure
OpenWindow(0, 0, 0, 350, 600, "Calculatrice", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 200, 30, "valeur1")
StringGadget(1, 100, 10, 250, 30, "")
TextGadget(2, 10, 40, 200, 30, "valeur2")
StringGadget(3, 100, 40, 250, 30, "")
ButtonGadget(4, 10, 100, 200, 30, "Plus")
ButtonGadget(5, 100, 100, 250, 30, "Moins")
BindGadgetEvent(4, @pls())
BindGadgetEvent(5, @mns())
; IDE Options = SpiderBasic 2.21 (Windows - x86)
; CursorPosition = 48
; FirstLine = 19
; Folding = -
; iOSAppOrientation = 0
; AndroidAppName = calculatrice
; AndroidAppVersion = 1.2.0
; AndroidAppPackageID = com.khalidel.clc
; AndroidAppOutput = calcul.apk
; AndroidAppOrientation = 0
; AndroidAppFullScreen
; AndroidAppEnableDebugger
; EnableXP
; CompileSourceDirectory