like what is "window.addEventListener("deviceorientation",p_fn)" expecting for the second parameter, an address, variable or a string?
Code: Select all
Procedure OrientHandlerFunc(*event)
Protected alpha.d,beta.d,gamma.d
!v_alpha = p_event.alpha;
!v_beta = p_event.beta;
!v_gamma = p_event.gamma
Debug "alpha " + StrD(alpha,2)
Debug "beta " + StrD(beta,2)
Debug "gamma " + StrD(gamma,2)
EndProcedure
;
Procedure IsDeviceOrientationEvent(*fn)
Protected result,alpha.d,beta.d,gamma.d
!if (window.DeviceOrientationEvent) {
!v_result = 1 ;
!window.addEventListener("deviceorientation",p_fn);
!}
ProcedureReturn result
EndProcedure
OpenWindow(0, 10, 10, 200, 50, "Desktop example",#PB_Window_Background)
ExamineDesktops()
Debug "Desktop dimension: " + DesktopWidth(0) + " x " + DesktopHeight(0)
Procedure TimerEvent()
Debug "Mouse position: x:" + DesktopMouseX() + " y:" + DesktopMouseY()
EndProcedure
x =IsDeviceOrientationEvent(@orienthandlerfunc())
Debug x
AddWindowTimer(0, 0, 1000) ; Add a timer every second (1000 ms)
BindEvent(#PB_Event_Timer, @TimerEvent())