fixed bug with broken 'page up/down' keys (for element list) in level editor
authorHolger Schemel <info@artsoft.org>
Wed, 19 Oct 2016 19:37:55 +0000 (21:37 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 19 Oct 2016 19:37:55 +0000 (21:37 +0200)
src/editor.c

index 1b72d69b4a9514921e37e88a2f21d25e06a825ee..479fec7af807ebc7dbd3bbb34c3f5a078c6a0197 100644 (file)
@@ -11885,6 +11885,7 @@ void HandleLevelEditorKeyInput(Key key)
   {
     int id = GADGET_ID_NONE;
     int new_element_shift = element_shift;
+    int step = ED_ELEMENTLIST_BUTTONS_VERT - 1;
     int i;
 
     switch (key)
@@ -11901,13 +11902,23 @@ void HandleLevelEditorKeyInput(Key key)
       case KSYM_Down:
        id = GADGET_ID_SCROLL_DOWN;
        break;
+
       case KSYM_Page_Up:
-       id = GADGET_ID_SCROLL_LIST_UP;
-       button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
-       break;
       case KSYM_Page_Down:
-       id = GADGET_ID_SCROLL_LIST_DOWN;
-       button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
+       step *= (key == KSYM_Page_Up ? -1 : +1);
+        element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
+
+        if (element_shift < 0)
+          element_shift = 0;
+        if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS)
+          element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS;
+
+        ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
+                     GDI_SCROLLBAR_ITEM_POSITION,
+                     element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
+
+       ModifyEditorElementList();
+
        break;
 
       case KSYM_Home: