Override function from lib

Just finalising some code for the android filewriter/reader.

I have implemented a textbox class which registers mouseEvent and keyEvent, to allow functionality by extending the keyboard class.

Currently I have hardcoded the text of the dialog box, however I would like users to be able to assign their own text or even their own function.

this is the keyboard class

//MouseFunctions class
public class KeyboardFunctions {
  public PApplet applet;
  public boolean kd,keydown;
  public String hist= "";
  public char key;
  public int keyCode;
  public TextArea1 textBox;
  public KeyboardFunctions() {
    registerMethod("keyEvent", this);
    registerMethod("mouseEvent", this);
  public void destroy(){
    //destroys the registermethod or something like that 
  public void register(TextArea1 p){
    applet = p.applet;
    textBox = p;
  void keyEvent(final KeyEvent evt) {
    switch(evt.getAction()) {
    case KeyEvent.PRESS:
      this.key = applet.key;
      hist += applet.key;
      this.keyCode = applet.keyCode;
      kd = true;
      case KeyEvent.RELEASE:
      kd = false;
  void mouseEvent(final MouseEvent evt) {
    switch(evt.getAction()) {
    case MouseEvent.PRESS:
  public void mousePressed(){
  void keyPressed() {
  void keyReleased() {

I can override the keypressed function in textarea, but how do I override this function in the sketch?


fileWriter sketch example

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import android.app.Activity;
import android.content.Context;
import android.os.Environment;
import android.content.DialogInterface;
import android.graphics.Color;
import android.widget.TextView;
import android.view.Gravity;
import processing.core.PApplet;
import android.app.Activity;
import android.app.AlertDialog;

fileOutput f;
BMS b;
PGraphics pg;
String s2 = "ohdoiahoi";
boolean keydown;
void settings() {
  size(600, 600);
void setup() {
  b = new BMS(this,true);
  f = new fileOutput(this);
  //f.textBox.closeKB = false;
  //key1 = new keyboard(this);
  f.setAndroidDialogue("No", "Yessss");
  //t2 = new TextArea(60+200,20,200,20,"Click to add text");

void draw() {
  background(0, 255, 0);
  text(frameRate, 100, 100);

void mousePressed() {

void keyPressed() {

1 Like