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.
Page Index Toggle Pages: 1
Hyperlink (Read 774 times)
Hyperlink
Nov 9th, 2009, 11:29am
 
Anyone know how to create a text based hyperlink.

I know the link() command, but how could I apply that to text without some massive mouse-over or creating a lot of underlying buttons?

Also, is there any way to embed the HTML into the processing sketch, so the web page pulls up in a defined area of your sketch?
Re: Hyperlink
Reply #1 - Nov 9th, 2009, 12:24pm
 
its not that massive...
actually pretty lightweight

Code:
PFont font;
String url = "http://www.processing.org";

void setup(){
size(400,400);
font = createFont("Arial",22);
textFont(font);
}

void draw(){
background(255);
fill(0);
cursor(ARROW);

if(mouseX>80 && mouseY>80-22 && mouseX<80+textWidth(url) && mouseY<80){
fill(0,0,255);
cursor(HAND);
}
text(url,80,80);

}

void mouseReleased(){
if(mouseX>80 && mouseY>80-22 && mouseX<80+textWidth(url) && mouseY<80)link(url);
}



and a little research would have shown you this.

Open websites in processing sketch.
A little Hack by marius Watz :
http://workshop.evolutionzone.com/2007/08/30/jdic-embedding-a-web-browser-in-java/

Re: Hyperlink
Reply #2 - Nov 9th, 2009, 5:06pm
 
Thanks, now I just need to figure out the JDIC. I can't get a version for mac to build.
Page Index Toggle Pages: 1