When I was bulding a text input (text area) with curses I encountered an issue, as I
was typing inside the text input, it loses focus, and focuses on a different window. Later on, I came to realise that I was refreshing
the window before typing, not after typing. Changing the position of the refresh, solved that problem.
Before:
def main(stdscr): # .. Other code while True: pad.refresh(PAD_MOVE_Y, PAD_MOVE_X, SCREEN_PAD_LEFT, SCREEN_PAD_TOP, SCREEN_HEIGHT, SCREEN_WIDTH) # Get input from pad c = pad.getch() if c == ord('q'): break # .. Other code else: y_pos, x_pos = pad.getyx() pad.addch(c)
After:
def main(stdscr): # .. Other code while True: # Get input from pad c = pad.getch() if c == ord('q'): break # .. Other code else: y_pos, x_pos = pad.getyx() pad.addch(c) pad.refresh(PAD_MOVE_Y, PAD_MOVE_X, SCREEN_PAD_LEFT, SCREEN_PAD_TOP, SCREEN_HEIGHT, SCREEN_WIDTH)