# G4P: How can I make text inside editText field be Capital letter?

**URL:** <https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984>\
**Category:** Libraries\
**Created:** [January 31, 2019, 5:13am UTC](https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984 "2019-01-31T05:13:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagagt505](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@sagagt505](https://discourse.processing.org/u/sagagt505)\
**Post date:** [January 31, 2019, 5:13am UTC](https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984/1 "2019-01-31T05:13:28Z")

</div>

Hello, I finally make some input field to insert my data but I need my text inside input field shows the only capital letter. No matter I input the text with a capital letter or not.

Example: If I want to type text “hi” or “HI”  
I want to show like this.  
 ![2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/000fd948bbe76799c3a111a7d09a90b347f835c2.png)

But now my program still show like this if I type text “hi”  
 ![1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0e7083196293108857dd7049dc9e5d661ff4742c.png)

Can you help me how to make the input text show the only capital letter? Thank you

Ps. From library G4P

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 31, 2019, 5:31am UTC](https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984/2 "2019-01-31T05:31:22Z")

</div>

-a- there is a event ENTERED  
that would be after the [enter]  
there you can call your own “text mod method”  
-b- there is a function  
[https://processing.org/reference/String\_toUpperCase\_.html](https://processing.org/reference/String_toUpperCase_.html)  
you can use for this.

```auto
/**
 This sketch is to demonstrate some features of GTextArea controls. 
 
 for Processing V2 and V3
 (c) 2015 Peter Lager
 
 */

import g4p_controls.*;

GTextArea txa1;

public void setup() {
  size(500, 300);
  G4P.setGlobalColorScheme(GCScheme.PURPLE_SCHEME);
  txa1 = new GTextArea(this, 10, 10, 480, 280);
  txa1.tag = "txa1";
  txa1.setPromptText("Text area 1");

}

public void draw() {
  background(200, 128, 200);
}

void workOnText() { // do something with the text
    println("get text area and check writing and save back ");
    String theText = txa1.getText();
    txa1.setText(theText.toUpperCase()); // change all to big
}

public void displayEvent(String name, GEvent event) {
  String extra = " event fired at " + millis() / 1000.0 + "s";
  print(name + " ");
  switch(event) {
  case CHANGED:
    println("CHANGED " + extra);
    break;
  case SELECTION_CHANGED:
    println("SELECTION_CHANGED " + extra);
    break;
  case LOST_FOCUS:
    println("LOST_FOCUS " + extra);
    break;
  case GETS_FOCUS:
    println("GETS_FOCUS " + extra);
    break;
  case ENTERED:
    println("ENTERED " + extra);  
    workOnText(); // add here
    break;
  default:
    println("UNKNOWN " + extra);
  }
}

public void handleTextEvents(GEditableTextControl textControl, GEvent event) { 
  displayEvent(textControl.tag, event);
}

```

---

<div class="post-metadata">

**Author:** ![sagagt505](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@sagagt505](https://discourse.processing.org/u/sagagt505)\
**Post date:** [January 31, 2019, 7:42am UTC](https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984/3 "2019-01-31T07:42:38Z")

</div>

Thank you. You are my life saver.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [January 31, 2019, 9:06am UTC](https://discourse.processing.org/t/g4p-how-can-i-make-text-inside-edittext-field-be-capital-letter/7984/4 "2019-01-31T09:06:59Z")

</div>

What is wrong with the Shift or Caps Lock key?
