# Drawing a line in processing after a region of the screen has been pressed and the mouse is being clicked

**URL:** <https://discourse.processing.org/t/drawing-a-line-in-processing-after-a-region-of-the-screen-has-been-pressed-and-the-mouse-is-being-clicked/25278>\
**Category:** Beginners\
**Created:** [November 8, 2020, 12:26pm UTC](https://discourse.processing.org/t/drawing-a-line-in-processing-after-a-region-of-the-screen-has-been-pressed-and-the-mouse-is-being-clicked/25278 "2020-11-08T12:26:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crimpqwe](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@crimpqwe](https://discourse.processing.org/u/crimpqwe)\
**Post date:** [November 8, 2020, 12:26pm UTC](https://discourse.processing.org/t/drawing-a-line-in-processing-after-a-region-of-the-screen-has-been-pressed-and-the-mouse-is-being-clicked/25278/1 "2020-11-08T12:26:25Z")

</div>

when i click the region it continually draws instead of when im holding the mouse. also ill figure out how to toggle the pencil when clicked later on. i am very new. ive tried some stuff with mouseclicked and mousebutton == left but i cant get it to work.  
thanks

```auto
}
void mousePressed() {
  if (mouseX > 772 && mouseX < 864 && mouseY > 1 && mouseY < 74) {
    drawPencil = true;
  }

      
  }
  {
    if (drawPencil) {
       stroke(255);
    line(mouseX, mouseY, pmouseX, pmouseY);

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 8, 2020, 4:06pm UTC](https://discourse.processing.org/t/drawing-a-line-in-processing-after-a-region-of-the-screen-has-been-pressed-and-the-mouse-is-being-clicked/25278/2 "2020-11-08T16:06:38Z")

</div>

Continued elsewhere

Chrisir
