void CheckClickedElement(out bool selectionChanged, SelectionElement clickedElement, KeyboardListener k, out int goToDirID)
        {
            goToDirID        = -1;
            selectionChanged = false;

            //right arrow movies fwd directory when one selected
            if (clickedElement == null)
            {
                if (k[KeyCode.RightArrow])
                {
                    if (selectionHandler.singleTracked)
                    {
                        if (firstSelected.isDirectory)
                        {
                            clickedElement = firstSelected;
                        }
                    }
                }
            }
            //left arrow goes back directory
            if (clickedElement == null)
            {
                if (k[KeyCode.LeftArrow])
                {
                    if (backButton != null)
                    {
                        clickedElement = backButton;
                    }
                }
            }


            if (clickedElement == null)
            {
                return;
            }


            if (clickedElement.isDirectory)
            {
                //if not already there

                if (clickedElement.elementID != currentShownDirectoryID)
                {
                    goToDirID = clickedElement.elementID;
                }
            }
            else   //element select
            {
                selectionHandler.OnObjectSelection(clickedElement, k.shift);
                selectionChanged = true;
            }
        }
        public void DrawElements(Action <KeyboardListener> checkHotkeys)
        {
            UpdateDirectoryTreeWindow(true);


            KeyboardListener keyboardListener = new KeyboardListener();

            bool mouseUp;

            dragDropHandler.InputListen(out mouseUp);



            bool searchChanged;
            // int pageOffset,


            Vector2 mousePosition = UnityEngine.Event.current.mousePosition;


            DrawElementsView(
                mousePosition,
                mouseUp,

                // pagination.pagesGUI,
                out searchChanged//,
                // out pageOffset,
                );


            dragDropHandler.UpdateLoop(mousePosition, selectionHandler.trackedRange);



            // bool paginationSuccess = pageOffset != 0 && pagination.SwitchPage(pageOffset);


            //check clicked element
            int  goToDirID;
            bool selectionChanged;

            CheckClickedElement(out selectionChanged, clickedElement, keyboardListener, out goToDirID);

            bool movedFolder = (goToDirID != -1 && MoveFolder(goToDirID));

            selectionChanged = selectionHandler.HandleDirectionalSelection(keyboardListener[KeyCode.UpArrow], keyboardListener[KeyCode.DownArrow], keyboardListener.shift, mainElements.Length - 1) || selectionChanged;

            shouldRebuild   = droppedOnReceiver || movedFolder || searchChanged;//|| paginationSuccess;
            shouldResetPage = movedFolder;

            if (!shouldRebuild && selectionChanged)
            {
                onSelectionChange();
            }

            checkHotkeys(keyboardListener);

            clickedElement = null;

            droppedOnReceiver = false;
        }