# UI-related stuff

**URL:** <https://discourse.processing.org/t/ui-related-stuff/20692>\
**Category:** Coding Questions\
**Created:** [May 9, 2020, 9:49pm UTC](https://discourse.processing.org/t/ui-related-stuff/20692 "2020-05-09T21:49:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharmadhruv741](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@sharmadhruv741](https://discourse.processing.org/u/sharmadhruv741)\
**Post date:** [May 9, 2020, 9:49pm UTC](https://discourse.processing.org/t/ui-related-stuff/20692/1 "2020-05-09T21:49:24Z")

</div>

Hello everybody. I was trying to make a simple, UI-based sketch where I am trying display ascII characters by sifting through them using a ‘slider’. But, I’ve got stuck. Any help?

```auto
  stroke (255);
  noFill ();
  rect (rectX, rectY, rectW, rectH);

  if (mousePressed) {
  
    if (linePos <= rectY) {
    
      linePos = rectY;
    
    } else if (linePos >= lineY) {
    
        linePos = lineY;
    }    

    g = map (mouseY, height, 0, 0, 255);  
  
    linePos = g;
  
    int i = int (g);
  
    char c = char (i);
  
  text(c, 20, 75);      
  
  }

  stroke (255, 0, 0);
  line (rectX, linePos, lineX, linePos);

```

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [May 9, 2020, 9:54pm UTC](https://discourse.processing.org/t/ui-related-stuff/20692/2 "2020-05-09T21:54:28Z")

</div>

Can you be more specific? Where exactly are you stuck?

---

<div class="post-metadata">

**Author:** ![sharmadhruv741](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@sharmadhruv741](https://discourse.processing.org/u/sharmadhruv741)\
**Post date:** [May 9, 2020, 9:57pm UTC](https://discourse.processing.org/t/ui-related-stuff/20692/3 "2020-05-09T21:57:38Z")

</div>

Sorry. There are two things which are not running right. Firstly, the line is not staying within the confines of the ‘box’ and secondly, it’s moving in the opposite direction to the mouse.
