theodore-norvell / PLAAY

Senior Design Project PLAAY (Programming Language for Adults And Youth)
2 stars 0 forks source link

Keyboarding #12

Open theodore-norvell opened 7 years ago

theodore-norvell commented 7 years ago

Pressing arrow keys should change the current selection.

Pressing certain other keys should insert the appropriate pallete item.

E.g ? applies the "if" template, cntl-n starts a new var decl node, a digit starts a new numeric literal, : applies an assignment template. And so on.

Typing a letter should insert a var node, use the letter as the first letter of the variable name, and make it so that typing more characters adds to the variables name. An enter or tab should end entry.

Similar for digits. Typing a " should insert a string.

theodore-norvell commented 7 years ago

It might be a good idea to add a method isDroppoint to pnode, so that isDroppoint(i) means that there should be a drop zone at position i under the node.

Also it would be a good idea to add a method isPlaceHolder() which means that the whole node can be selected using left or right.

theodore-norvell commented 7 years ago

As an example of left and right, consider this tree with anchor and focus shown by ! and ^.

theodore-norvell commented 7 years ago

Some more thoughts: Here are some more ideas

theodore-norvell commented 7 years ago

Two problems with keyboarding remain currently (2017 March 13). First if the keyboard focus is on an INPUT element, then we should not be handling events at the document level. For example, the backspace should be interpreted by the INPUT element only and mean delete 1 character instead of also deleting the current selection. Second its not clear whether preventDefault should be active or not. I commented out e.preventDefault() because it was interfering with editing input items and also because it interferes with sending commands to the browser (e.g. CNTL-T) should open a new tab in the browser. Perhaps the right thing to do to solve both these problems is to have two editing modes. One for when the keyboard focus is on an input element and one for when it is not. Call them InputMode and RegularEditMode. (Later there might be more modes.) When it is in InputMode, all keyboard events are ignored by our handler. When it is in RegularEditMode keyboard events that the application understands are prevented from propagating (e.g. CMD-B) but other key events (e.g. CNTL-T) are allowed to propagate.