comp • gb.ncurses • window • setfocus

Window.SetFocus (gb.ncurses)

Sub SetFocus ( )

Set the focus on the particular Window so it raises the Read event.

All Windows are connected to the standard input of the program. That is the only way they may receive data. So only one window at a time can be allowed to raise the Read event and read input from there. This decision is made by means of the focus. If one Window gets the focus, only that window will be able to raise events.

At program startup, no Window has the focus, even not the auto-instance of the Window class. Consequently, by default, nothing in the gb.ncurses component keeps a program alive after the Main routine has been executed. If you wish to enter a GUI-like event loop, you have to Window.SetFocus() explicitly.


Public Sub Main()
  ' Don't close the program after Main finishes, as we now will begin watching the stdin.

Public Sub Window_Read()
  If Last.WaitKey() = Key["q"] Then

See also