Hello.
What's the best way to call functions between files?
my file teste4app.mc
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;
import Toybox.ActivityRecording;
import Toybox.Application.Storage;
import Toybox.Position;
class teste4App extends Application.AppBase {
function getInitialView() as Array<Views or InputDelegates>? {
var view = new teste4View();
var delegate = new teste4Delegate();
return [ new teste4View(), new teste4Delegate(view) ];
}
function onKey(evt) {
if (evt.getKey() == 4) { System.println("start session");
StartRecordSession();
}
}
my file teste4view.mc
import Toybox.Graphics;
import Toybox.WatchUi;
import Toybox.Lang;
using Toybox.Activity;
using Toybox.ActivityRecording;
using Toybox.Timer;
using Toybox.Attention;
import Toybox.Position;
class teste4View extends WatchUi.View {
function StartRecordSession() {
System.println("lets start");
}
}
I already tried this:
teste4app.mc
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;
import Toybox.ActivityRecording;
import Toybox.Application.Storage;
import Toybox.Position;
class teste4App extends Application.AppBase {
function getInitialView() as Array<Views or InputDelegates>? {
var view = new teste4View();
var delegate = new teste4Delegate();
return [ new teste4View(), new teste4Delegate(view) ];
}
}
testeview4.mc
import Toybox.Graphics;
import Toybox.WatchUi;
import Toybox.Lang;
using Toybox.Activity;
using Toybox.ActivityRecording;
using Toybox.Timer;
using Toybox.Attention;
import Toybox.Position;
class teste4View extends WatchUi.View {
function StartRecordSession() {
System.println("lets start");
}
}
class teste4Delegate extends WatchUi.BehaviorDelegate {
function onKey(evt) {
if (evt.getKey() == 4) { System.println("Vamos começar a gravar a sessão");
//StartRecordSession();
StartRecordSession();
}
}
but always got:
Class 'teste4Delegate' does not initialize its super class, 'BehaviorDelegate'
Thanks!!
btw, why OnKey() doesn't work on view file ? but work on app file ??
thanks!!