We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › controlp5 ControlWindowCanvas: adding methods
Page Index Toggle Pages: 1
controlp5 ControlWindowCanvas: adding methods (Read 441 times)
controlp5 ControlWindowCanvas: adding methods
Nov 9th, 2008, 3:49pm
 
im am having issues adding a method addText(String) to the class StoryCanvas which extends ControlWindowCanvas. When addText("test")  is called the compiler says "The function addText(String) does not exist". Is it not possible to add methods to classes which inherit ControlWindowCanvas?

Code:

import controlP5.*;

ControlP5 controlP5;

ControlWindow controlWindow;
ControlWindowCanvas storyCanvas;

void setup() {
 controlP5 = new ControlP5(this);

 controlWindow = controlP5.addControlWindow("controlP5window", 100, 100, 400, 400);
 controlWindow.setBackground(color(0));

 storyCanvas = new StoryCanvas();
 storyCanvas.addText("addText");

 controlWindow.addCanvas(storyCanvas);
}

class StoryCanvas extends ControlWindowCanvas {
 String text =  "";

 StoryCanvas() {

 }

 public void addText(String itext) {
   text = itext;
 }

 public void draw(PApplet p) {

 }
}




Re: controlp5 ControlWindowCanvas: adding methods
Reply #1 - Nov 9th, 2008, 4:47pm
 
you have to define your variable to be of type "StoryCanvas", otherwise Processing will not see the functions you've added:

StoryCanvas storyCanvas;

F
Re: controlp5 ControlWindowCanvas: adding methods
Reply #2 - Nov 9th, 2008, 4:57pm
 
hah! thanks for seeing that!
Page Index Toggle Pages: 1