Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input done right! :D #53

Open
goblinfactory opened this issue Jan 24, 2020 · 0 comments
Open

Input done right! :D #53

goblinfactory opened this issue Jan 24, 2020 · 0 comments
Assignees
Labels
feature request version 8 planned for version 8

Comments

@goblinfactory
Copy link
Owner

goblinfactory commented Jan 24, 2020

I want to be able to capture input safely at a region on the screen or at the current cursor position, and be able to specify the data type to limit to, and for the input to be constrained by the containing window.

For example

var window = Window.OpenBox("name", 40,3);
window.Write("Name:   ");
var name = window.ReadText(60, { Scroll = true }); // limits entry to 60 characters, allow scrolling
window.Write("Age:      ");
var age = window.ReadNumber(0, 120); 
window.Write("Discount: ");
var discount = window.ReadDecimal(0, 100, 2); // min, max, decimals 

Because the inputs are being entered inside a window, all text must be clipped by the containing window.

Scrolling content

If the text area left for the input is less than the available characters, then when the user reaches the end of the line, the textbox must scroll the contents.

for example in the code above the window is only 40 characters wide,and the caption takes up space, so the name which can be up to 60 characters, will cause the text to scroll when.

Support keystrokes

  • home, to move cursor to first character
  • end, to last
  • delete
  • insert (toggle between insert and overwrite)
  • control + arrow, highlight word
  • tab, complete entry from previous entries
    (to be completed)

Input at X,Y

var name = window.ReadAt(10,10, Input.Number, width:30);

Move between inputs using tab and arrow keys

The arrow keys will move you to the next active input based on the inputs location on the screen. Pressing up will move you to the nearest input above you, etc.

// pseudo code
var person = Window.Read<Person>(CaptionWidth:14, 
  p => 
  new Input(p.Name, 10,10, Text, width:30, caption:"Name"),
   new Input(p.Surname, 0,11, Text, width:30, caption:"Surname"), 
   new Input(p.X, 0, 1, Integer(0,50), width:4, caption:"X:"), 
   new Input(p.Y, 6,1, Integer(0,50), width:4, caption:"Y:"), 
);

Pressing tab moves you between inputs, inputs are highlighted with a default theme, typically black on white for active input, and white and black for inactive.

Themeable inputs

be able to set the foreground and background color of active, current, inactive items.

  • active : means that the item is part of an input.
  • current: user has tabbed into the entry
  • inactive : user has finished entering text, and the value is now in readonly display mode.

cascading theme to reduce code required to render

Inputs to read their theme from a window.
if a parent window has no theme, then the check for theme bubbles up to the parents parent, so that themes cascade.
Windows to come with decent default themes.

@goblinfactory goblinfactory self-assigned this Jan 24, 2020
@goblinfactory goblinfactory added the version 8 planned for version 8 label Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request version 8 planned for version 8
Projects
None yet
Development

No branches or pull requests

1 participant