From 595f7e4d46abcc103b786cb8a68a740aeef7f140 Mon Sep 17 00:00:00 2001 From: T!M Greller Date: Sun, 24 Feb 2019 16:57:23 +0100 Subject: [PATCH] code writing improved: - after entering a command the next cell gets focussed - commands get only written in the first col --- Registermaschine.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Registermaschine.js b/Registermaschine.js index b77cac4..8b9e537 100644 --- a/Registermaschine.js +++ b/Registermaschine.js @@ -44,8 +44,20 @@ class Registermaschine { handleCmdInput( e ){ if( $storage.focus ){ - $storage.focus.value = e.target.getAttribute('id'); - $storage.focus.focus(); + let i = $storage.speicherZellen.indexOf($storage.focus); + + let focus = $storage.focus; + if( i%2 != 0 && i != -1 && i+1 < $storage.speicherZellen.length){ + focus = $storage.speicherZellen[++i]; + } + + focus.value = e.target.getAttribute('id'); + + if( i == -1 || i+1 >= $storage.speicherZellen.length ){ + focus.focus(); + } else { + $storage.speicherZellen[++i].focus(); + } } }