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 & HelpSyntax Questions › selectInput() not working in Eclipse
Page Index Toggle Pages: 1
selectInput() not working in Eclipse (Read 696 times)
selectInput() not working in Eclipse
Dec 19th, 2009, 9:38am
 
Hello all,

I've been trying to get the function selectInput() working in Eclipse but it doesn't seem to recognize it.

My questions are if selectInput() is derived from another library outside core.jar and how would I make this work in Eclipse?

thanks!
eep Smiley
Re: selectInput() not working in Eclipse
Reply #1 - Dec 19th, 2009, 11:08am
 
Show how you use it.
selectInput is a method of PApplet, ensure you are calling it from this context or like pa.selectInput() where pa is a PApplet object.
Re: selectInput() not working in Eclipse
Reply #2 - Dec 19th, 2009, 11:51am
 
Hey thanks for the response PhiLho,

I just solved the problem from your response.  Below is the snippet of code that I was causing the selectInput to be invalid:

if(type[0].equals("rc")){
  PApplet.println("RECORD =" + this.focusId);
  this.record();
} else {
         PApplet.println("LOAD  =" + this.focusId);
         String loadPath = PApplet.selectInput();
}

As you can see I was using PApplet directly.  It worked for println() function because it is static but selectInput() isn't.  Therefore what is needed is to create another variable of type PApplet that is referenced from the parent.  Then that will work!  Below is the changed code:

// constructor
public myClass(PApplet pa){
  this.pa = pa;
}

...

if(type[0].equals("rc")){
  PApplet.println("RECORD =" + this.focusId);
  this.record();
} else {
         PApplet.println("LOAD  =" + this.focusId);
         String loadPath = this.pa.selectInput();
}
Re: selectInput() not working in Eclipse
Reply #3 - Dec 20th, 2009, 1:08am
 
Glad I helped.
For those wondering, in Java context, Processing functions are of two kinds: static functions like println are just plain functions, needing no context. Methods, like selectInput, need the PApplet context, because it attaches the dialog to the parent frame.

Note: except in the constructor where you need to distinguish pa class field from pa parameter (others just use different names...), you can get rid of all this. decorations: + focusId, = pa.selectInput() etc. I find this less distracting... Smiley
Page Index Toggle Pages: 1