No Action Event for Timer Class? (API 2.0)

Xojo.Core.Timer is Deprecated, and the API 2.0 Timer class looks to be supported in iOS target but not it’s Action event? (which is kind of a big one :smiley:)

Is the only recourse (for now) to use Xojo.Core.Timer for iOS builds?

Timer.Run?

Isn’t this for a WebTimer Greg?

Docs shows both

https://documentation.xojo.com/api/language/timer.html

Not for Action event handler though…

image

(and the compiler doesn’t seem to recognize Action in iOS Builds in latest Xojo release.

Here I see:

Oh. Are you saying the class isn’t supported at all @Rick_Araujo ?

This may be the case, though the compiler seems to be OK with creating an instance of Timer in an iOS project…

I’m just going to use Xojo.Core.Timer for now.

For iOS, use the Run() event, because there they say “for Mobile”

image

1 Like

And… this appears to be a Language Reference issue. The local Language Reference is not showing the Run event. @Paul_Lefebvre - something to look at maybe?

Timer.Run doesn’t seem to autocomplete either in iOS projects, fyi.

Thanks for the assistance @Rick_Araujo and @Greg_O_Lone Looks like I’m all sorted now.

1 Like

One last followup to this to help fellow travelers on the Xojo road.

At least as of this writing, the “Run” Event is currently not supported on Desktop/Console/Web targets, so if you want to write code which uses timers and works on Desktop/Console you’ll need to do something like this:

self.MyTimer = new Timer
self.MyTimer.RunMode = timer.RunModes.Multiple
self.MyTimer.Period = 500

#if TargetIOS then
  AddHandler self.MyTimer.Run, AddressOf self.actionHandler

#else //handle other targets
  AddHandler self.MyTimer.Action, AddressOf self.actionHandler

#endif

This should let you have a single event handler for all targets. (at least until Xojo adds the “Run” Event to the Timer class for Desktop/Web/Console)

actionHandler would be declared like this in a class:

Sub actionHandler(t as Timer)
  //Do stuff here
End Sub
2 Likes