Hello, I'm trying to capture a keypress in the delegate of a class so that I can start activity recording as soon as the user has tapped any button. However, when I call the "buttonPressed" function that is in my main class from the delegate I get a do not recognize symbol error for one of my globals as shown below:

I presume this is because I am calling the function from another class and hence cannot interact with that class's globals. However, the sample file Input seems to be able to do this.
This is my code for the main class:
import Toybox.Graphics;
import Toybox.WatchUi;
import Toybox.Timer;
import Toybox.AntPlus;
import Toybox.Activity;
import Toybox.Lang;
class FTPInputDelegate extends WatchUi.BehaviorDelegate {
private var _view as FTPCalculator;
//! Constructor
//! @param view The app view
public function initialize(view as FTPCalculator) {
BehaviorDelegate.initialize();
_view = view;
}
}
class FTPCalculator extends WatchUi.View {
var currentColour = Graphics.COLOR_WHITE;
var listener = new MyBikePowerListener();
var bikePower = new AntPlus.BikePower(null);
private var keyPressed = false;
var timer = new Timer.Timer();
var counter =0;
var _session as Session?;// set up session variable
hidden var keys;
private var _action as Action;
private var _behavior as Behavior;
private var _button as Button;
var totalPowerOutput = 0;
function initialize() {
timer.start( method(:onTimer), 200, true ); //makes page refresh every 50 milliseconds
View.initialize();
keys = new [26];
}
public function buttonPressed() as Void{
keyPressed = true;
if (Toybox has :ActivityRecording) {
if (!isSessionRecording()) {
startRecording();
}
}
System.println("fjsdkjfbQ");
}
//! Stop the recording if necessary
public function stopRecording() as Void {
if ((Toybox has :ActivityRecording) && isSessionRecording()) {
_session.stop();
_session.save();
_session = null;
WatchUi.requestUpdate();
}
}
public function isSessionRecording() as Boolean {
return (_session != null) && _session.isRecording();
}
//! Start recording a session
public function startRecording() as Void {
_session = ActivityRecording.createSession({ // set up recording session
:name=>"Biking", // set session name
:sport=>ActivityRecording.SPORT_GENERIC, // set sport type
:subSport=>ActivityRecording.SUB_SPORT_GENERIC // set sub sport type
});
_session.start();
WatchUi.requestUpdate();
}
function onHide(){
if (Toybox has :ActivityRecording) {
if (isSessionRecording()) {
stopRecording();
}
}
timer.stop();
}
function onTimer() {
WatchUi.requestUpdate(); //call on update
//WatchUi.onUpdate(dc);
}
// Load your resources here
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() as Void {
timer = new Timer.Timer();
timer.start( method(:onTimer), 1000, true );
}
function HMSConverter(totalSeconds){ //got this fropm forums #
totalSeconds = totalSeconds /1000;
var hours = (totalSeconds / 3600).toNumber();
var minutes = ((totalSeconds - hours * 3600) / 60).toNumber();
var seconds = totalSeconds - hours * 3600 - minutes * 60;
var timeString = Lang.format("$1$:$2$:$3$", [hours, minutes, seconds]);
return timeString;
}
// Update the view
function onUpdate(dc as Dc) as Void {
dc.clear();
dc.setColor(currentColour, Graphics.COLOR_TRANSPARENT); //sets background for recovery
dc.fillRectangle(0, 0, dc.getWidth(), dc.getHeight());
counter +=1;
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_WHITE);
dc.drawText(dc.getWidth() / 2, dc.getHeight() / 2, Graphics.FONT_MEDIUM, counter, Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
if(keyPressed){
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_WHITE);
dc.drawText(dc.getWidth() / 4, dc.getHeight() / 4, Graphics.FONT_MEDIUM, "Key Pressed", Graphics.TEXT_JUSTIFY_CENTER);
}
if (Toybox has :ActivityRecording) {
// Draw the instructions
if (!isSessionRecording()) {
dc.setColor(Graphics.COLOR_BLUE, Graphics.COLOR_WHITE);
dc.drawText(dc.getWidth() / 2, dc.getHeight() / 2, Graphics.FONT_MEDIUM, "Press Menu to\nStart Recording your FTP", Graphics.TEXT_JUSTIFY_CENTER);
}else{
var activeInfo = Activity.getActivityInfo();
dc.setColor(Graphics.COLOR_BLUE, Graphics.COLOR_WHITE);
dc.drawText(dc.getWidth() / 2, dc.getHeight() / 2, Graphics.FONT_MEDIUM, "Recording", Graphics.TEXT_JUSTIFY_CENTER);
}
}
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
}
and this is the code for my delegate:
import Toybox.Lang;
import Toybox.WatchUi;
//! Input handler for the detail views
class FTPDelegate extends WatchUi.BehaviorDelegate {
//! Constructor
private var _parentView as FTPCalculator;
public function initialize(view as FTPCalculator) {
_parentView = view;
BehaviorDelegate.initialize();
}
//! Handle back behavior
//! @return true if handled, false otherwise
public function onBack() as Boolean {
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
return true;
}
//! Handle a physical button being pressed and released
//! @param evt The key event that occurred
//! @return true if handled, false otherwise
public function onKey(evt as KeyEvent) as Boolean {
System.println("on key");
_parentView.buttonPressed();
return true;
}
//! Handle a physical button being pressed
//! @param evt The key event that occurred
//! @return true if handled, false otherwise
public function onKeyPressed(evt as KeyEvent) as Boolean {
System.println("keypressed");
return true;
}
//! Handle a physical button being released
//! @param evt The key event that occurred
//! @return true if handled, false otherwise
public function onKeyReleased(evt as KeyEvent) as Boolean {
System.println("on key released");
return true;
}
}
Any help with this would be great, cheers