mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.27k stars 242 forks source link

Cannot pollInput and write to textBox at the same time #414

Closed HectorPascual closed 5 years ago

HectorPascual commented 5 years ago

Hi,

I've got a Window which contains a panel with some components, one of them is a textBox in which I type some input sent to a Socket stream.

I might want to exit the program and detect keys to make some alternate functions, like detecting scape and clossing the screen, but I've got the problem that if I try pollInput, my input won't go to the textBox anymore.

This is my function to poll the input :

public void checkKeys(){

        Thread readKeys = new Thread(new Runnable() {
            public void run() {
                try {
                    while (true) {
                        keyStroke = screen.pollInput();
                        if (keyStroke != null && keyStroke.getKeyType() == KeyType.Escape) {
                            window.close();
                            System.exit(0); //exits the process
                        }
                    }
                }catch(IOException e){

                }
            }
        });
        readKeys.start();
   }

Any ideas?

HectorPascual commented 5 years ago

Solved, https://stackoverflow.com/questions/36938655/lanterna-3-how-can-i-get-keypad-inputs-like-enter-or-f1

mabe02 commented 5 years ago

Amazing with people actually giving helpful advise on Lanterna at Stack Overflow!