# mouseClicked new sketch

**URL:** https://discourse.processing.org/t/mouseclicked-new-sketch/9616
**Category:** Coding Questions
**Tags:** homework
**Created:** [March 25, 2019, 6:42pm UTC](https://discourse.processing.org/t/mouseclicked-new-sketch/9616 "2019-03-25T18:42:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nothingnew](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@nothingnew](https://discourse.processing.org/u/nothingnew)
#### Post date: [March 25, 2019, 6:42pm UTC](https://discourse.processing.org/t/mouseclicked-new-sketch/9616/1 "2019-03-25T18:42:30Z")

</div>

Hi, I want to make my code when mouse is clicked it can open 2nd sketch.  
right now it only appears when I click and released my mouse. ( i know it is because it is in void draw)  
I want it to be hold the 2nd sketch and have interaction there too.

is there a possible way?

---

<div class="post-metadata">

### Author: ![TheWizardBear](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/thewizardbear/32/3552_2.png) [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)
#### Post date: [March 25, 2019, 8:01pm UTC](https://discourse.processing.org/t/mouseclicked-new-sketch/9616/2 "2019-03-25T20:01:47Z")

</div>

Hi @nothingnew,

Can we see your code?

---

<div class="post-metadata">

### Author: ![nothingnew](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@nothingnew](https://discourse.processing.org/u/nothingnew)
#### Post date: [March 25, 2019, 9:25pm UTC](https://discourse.processing.org/t/mouseclicked-new-sketch/9616/4 "2019-03-25T21:25:22Z")

</div>

```auto

boolean pos = false;
boolean pos2 = false;

void setup() {
  size(550, 800, P3D);
}
void draw() {
  background(255);

  PFont f = createFont ("Garamond", 20);
  fill(0);
  textFont(f);
  textSize(20);

  String q = "real";
  String q2 = "dream";

  if (mouseY > 0 && mouseY < height/2
    && mouseX > 0 && mouseX < width)
  {
    fill(0);
  } else {
    noStroke();
    fill(255);
  }
  rect(0, 0, width, height/2);

  if (mouseY > 400 && mouseY < height
    && mouseX > 0 && mouseX < width)
  {
    fill(0);
  } else {
    noStroke();
    fill(255);
  }
  rect(0, 400, width, height/2);

  if (mouseY > 0 && mouseY < height/2
    && mouseX > 0 && mouseX < width)
  {
    fill(255);
  } else {
    fill(0);
  }
  textSize(18);
  text(q, width/2, height/4);

  if (mouseY > 400 && mouseY < height
    && mouseX > 0 && mouseX < width)
  {
    fill(255);
  } else {
    fill(0);
  }
  textSize(18);
  text(q2, width/2-10, 600);

  //void mouseClicked() {

  // if (mouseY > 350 && mouseY < 350+35
  // && mouseX > 228 && mouseX < 228+90)
  // {
  // pos = true;
  // drawDream();
  // } else {
  // pos = false;
  // }
  //}

String t = "inceptioninceptioninception";
float radius = 120;
float angle = radians(360) / t.length() ;
float x, y, z; 
PFont f;
int numRings = 6;

void drawDream() {
  f = createFont ("Serif", 20);
  textFont(f);
  textAlign(CENTER);
  textMode(SHAPE);
  textSize(20);
  smooth(8);
  fill(255);
  
  numRings = 8;
  background(0);
  lights();

  translate(mouseX, mouseY);
  rotateX(PI/2.5);
  rotateY(0);
  rotate(frameCount * .04);

  for (int i = 0; i < numRings; i++) {
    translate(0, 0, i+30);
    wordRing(radius, angle);
  }
}
 
void wordRing (float thisRadius, float thisAngle) {

  for (int i=0; i< t.length(); i++) {
    x = cos(thisAngle * i) * thisRadius;
    y = sin(thisAngle * i) * thisRadius;

    pushMatrix();
    translate(x, y);
    rotateX(-HALF_PI);
    rotateY(-thisAngle*i + HALF_PI);
    text(t.charAt((t.length()-1) - i), 0, 0);
    popMatrix();
  }
}

```

sorry, it is quite messy…

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [March 27, 2019, 6:09am UTC](https://discourse.processing.org/t/mouseclicked-new-sketch/9616/5 "2019-03-27T06:09:51Z")

</div>

You can create a new sketch if you check this example: [https://forum.processing.org/two/discussion/comment/72574/#Comment\_72574](https://forum.processing.org/two/discussion/comment/72574/#Comment_72574)

But maybe you meant to say you want to work with multiple states in the same sketch?: [https://forum.processing.org/two/discussion/24867/make-the-typing-appear-after-the-mouse-click-and-stay-on-the-screen#latest](https://forum.processing.org/two/discussion/24867/make-the-typing-appear-after-the-mouse-click-and-stay-on-the-screen#latest)

Kf
