Repository: movingblocks/terasology
Issue: Game behaves poorly on interacting with the windowed/fullscreen option

### What you were trying to do

Change from windowed to fullscreen mode. Expected that interacting with (clicking/activating) the display mode drop-down would show all the available options on one interaction then let me choose with a second interaction

### What actually happened

Game window disappeared (as if about to change display mode) but game kept running and the whole OS started mildly freaking out (seems like it outright crashed an OS process for @Adrijaned on Linux). It feels like the game gets stuck in a state where it is trying to swap windowed state constantly

Theory is that it relates to how activating the UI widget works, likely after tabbing was introduced. Actually tabbing to the widget and varying the display mode with down arrow works. Only clicking the widget with the mouse makes the game freak out.

It seems like too much happens at once. Interacting with the drop-down should first reveal the options then not activate a given item until a second interaction (second mouse click or hitting enter after selecting an option with the arrow keys)

May similarly affect the drop-down widget in general? See also #3581 and #3561 for potential clues

### How to reproduce

* Run game
* Go to video settings
* Click on the Display Mode drop-down (using tab plus arrow keys still work fine)

If other drop-downs are also affected it may be easier to test with those. After interacting poorly with the display mode drop-down i have to force-kill the game - it may destabilize your OS, beware!

### Log details and game version

No applicable logging, latest develop branch as of this write-up

### Computer details

Win10 with a 4k monitor in case it matters

Changed files:
engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdown.java
engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdownScrollable.java

diff --git a/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdown.java b/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdown.java
index ae4a319e5..188408a74 100644
--- a/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdown.java
+++ b/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdown.java
@@ -110,7 +110,7 @@ public void onDraw(Canvas canvas) {
             for (int i = 0; i < optionListeners.size(); ++i) {
                 if (optionListeners.get(i).isMouseOver()) {
                     canvas.setMode(HOVER_MODE);
-                } else if (i==highlighted) {
+                } else if (i==highlighted && TabbingManager.focusedWidget != null && TabbingManager.focusedWidget.equals(this)) {
                     canvas.setMode(HOVER_MODE);
                     setSelection(getOptions().get(highlighted));
                 } else {
diff --git a/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdownScrollable.java b/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdownScrollable.java
index 7bf230520..5b91489f7 100644
--- a/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdownScrollable.java
+++ b/engine/src/main/java/org/terasology/rendering/nui/widgets/UIDropdownScrollable.java
@@ -24,6 +24,7 @@
 import org.terasology.rendering.nui.Canvas;
 import org.terasology.rendering.nui.InteractionListener;
 import org.terasology.rendering.nui.SubRegion;
+import org.terasology.rendering.nui.TabbingManager;
 import org.terasology.rendering.nui.databinding.Binding;
 import org.terasology.rendering.nui.databinding.DefaultBinding;
 import org.terasology.rendering.nui.events.NUIMouseClickEvent;
@@ -191,7 +192,7 @@ private void createScrollbarItems(Canvas canvas, Rect2i frame, Font font, Border
     private void readItemMouseOver(Canvas canvas, int i) {
         if (optionListeners.get(i).isMouseOver()) {
             canvas.setMode(HOVER_MODE);
-        } else if (i == highlighted) {
+        } else if (i == highlighted && TabbingManager.focusedWidget != null && TabbingManager.focusedWidget.equals(this)) {
             canvas.setMode(HOVER_MODE);
             setSelection(getOptions().get(highlighted));
         } else {