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 › Beginner's InterFascia question.
Page Index Toggle Pages: 1
Beginner's InterFascia question. (Read 1666 times)
Beginner's InterFascia question.
Feb 17th, 2010, 12:30pm
 
I've just found this library, which seems to b exactly what I need - a simple box that cn have text typed into it, then a copy of the string typed saved when the enter key is pressed. This is the example code from the library for a text field which is great, but it didnt seem to work with the sketch I have already so I wanted to test it out my making it print "click' when it was clicked on, but even that's not working...could someone explain to me what the actionPerformed() is triggered by? - the docs. say:

Quote:
If it exists, the actionPerfomed() method is called every time a GUI component generates an event. It is passed a GUIEvent as an argument. Events are generated on button click, checkbox state change, radio button state change, and text field focus change.

The event notification is sent to the listener declared in the particular component's addActionListener() method.



Syntax

void actionPerformed (GUIEvent e) {
  // Statements here will be executed whenever a GUIEvent is generated
}

..but nothing happens when im clicking.

Quote:
import interfascia.*;

GUIController c;
IFTextField t;
IFLabel l;

void setup() {
  size(200, 100);
  background(150);
  
  c = new GUIController(this);
  t = new IFTextField("Text Field", 25, 30, 150);
  l = new IFLabel("", 25, 70);
  
  c.add(t);
  c.add(l);
  
  t.addActionListener(this);
  
}

void draw() {
  
}

void actionPerformed(GUIEvent e) {
  println("click");
  if (e.getMessage().equals("Completed")) {
    l.setLabel(t.getValue());
  }
}



Hope that makes some sort of sense! Thanks.
Re: Beginner's InterFascia question.
Reply #1 - Feb 18th, 2010, 12:27am
 
I downloaded Interfascia, installed it, restarted Processing, pasted the code you show, it worked fine...
Re: Beginner's InterFascia question.
Reply #2 - Feb 18th, 2010, 8:14am
 
Yes it works, but I dont really understand how Shocked

Can you see how I might change the actionPerformed (which currently seems to be typing characters) to run when the text field is selected? - I thought that might help me work out why I couldn't select the text field in my own sketch.
I've not had much luck using libraries frankly so I'm not quite sure how much they can be modified, i'm trying to get through some of the reference on interFascia but it seems like I just haven't quite 'got it' yet!

edit: - it seems that rotating the box stops it from working.
Re: Beginner's InterFascia question.
Reply #3 - Feb 18th, 2010, 9:08am
 
In this library the actionPerformed method is called when :-

1) The Enter key is pressed (Completed)
2) The text in the field changes (Modified)
3) Some or all of the text is copied (Copy)
4) Some text is pasted into the field (Paste)

The IFTextField does respond to mouse events and that would require changes in the source code of the library. Looking at the InterFacsia website and the source code this library does not appear to have been updated since mid 2007.

I also tried to copy and paste text between IFTextFields and that didn't appear to work, if that's what you want then you might try the GTextField component from the G4P library.

Re: Beginner's InterFascia question.
Reply #4 - Feb 18th, 2010, 4:22pm
 
Ok, I'll try to work around it using the library as is, and i'll have a look at the one you suggested thanks. As a guide for a determined codephobe, should I generally just try to find library examples that pretty much look like what I want and leave them alone? L.
Re: Beginner's InterFascia question.
Reply #5 - Feb 19th, 2010, 4:05am
 
Quote:
As a guide for a determined codephobe, should I generally just try to find library examples that pretty much look like what I want and leave them alone? L.


Do you mean "or leave them alone"?

Library examples are probably the most useful resource for codephobes but only if they are well commented/documented. Unfortunately some libraries come with no examples or examples that are poorly commented.

A key resource for library users is the library creator (if they are still using the Discourse)
Smiley
Page Index Toggle Pages: 1