From 603ad275792d3b638bc094c436384e21fc16c00f Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sun, 13 Jan 2013 23:16:10 +0100 Subject: [PATCH] Changed behaviour when inserting/changing current value * if there is a value already we keep that keys type * if there isn't a value we grab the key type from the previous key Closes #71 --- ogl_editor/src/Editor.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index e780f9a..5a8fed1 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -644,10 +644,20 @@ static void endEditing() if (track->num_keys > 0) { int idx = sync_find_key(track, getRowPos()); - if (idx < 0) - idx = -idx - 1; - key.type = track->keys[emaxi(idx - 1, 0)].type; + if (idx > 0) + { + // exact match, keep current type + key.type = track->keys[emaxi(idx, 0)].type; + } + else + { + // no match, grab type from previous key + if (idx < 0) + idx = -idx - 1; + + key.type = track->keys[emaxi(idx - 1, 0)].type; + } } track_name = track->name; @@ -1338,9 +1348,7 @@ void Editor_menuEvent(int menuItem) case EDITOR_MENU_NEXT_KEY : case EDITOR_MENU_PLAY : { - if (is_editing) - endEditing(); - break; + endEditing(); } } @@ -1492,7 +1500,14 @@ bool Editor_keyDown(int key, int keyCode, int modifiers) case EMGUI_KEY_TAB : case EMGUI_KEY_ENTER : { - endEditing(); + if (is_editing) + { + endEditing(); + + if (key == EMGUI_KEY_ENTER) + return true; + } + break; }