Fix palette hit-test bug and tab/shift-tab bug