goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
718 stars 62 forks source link

Window Keyboard event handler - pass keyboard events to child windows #55

Open goblinfactory opened 4 years ago

goblinfactory commented 4 years ago

Any window must be able to start monitoring keystrokes, and keep track of active child windows that any keyboard commands are then passed to.

e.g.

var scores = window.OpenBox("scores", 50,20); 
scores.Run();

The default keystroke to move between active windows that have tab sequence number is the Tab key, but this can be overridden. When used in conjuction with multi-inputs (form input) then tab no longer moves between individual inputs, that will be left to the arrow keys or enter key.

Example

var parentWindow = new Window();
var teamA = parentWindow.SplitLeft("team A");
var teamB = parentWindow.splitRight("team B");
var getNames = GetNameInputs(); // returns an array of ReadLine();
teamA.Add(getNames);
teamB.Add(getNames);
parentWindow.Run();

Calling Run, will cause first window to have focus, and all keyboard events are sent to the controls inside that window. Pressing tab, will switch focus between the two window objects, teamA and teamB, and will cause each window to change their style indicating selection.