Split keyboard and mouse focus.

Fixes #3304.
Fixes #2075.
Fixes C&C chat focus bug.
This commit is contained in:
Paul Chote
2013-07-27 20:38:05 +12:00
parent ea36d05fc5
commit 7c91d6976d
16 changed files with 93 additions and 87 deletions

View File

@@ -215,7 +215,8 @@ namespace OpenRA
worldRenderer = new WorldRenderer(orderManager.world); worldRenderer = new WorldRenderer(orderManager.world);
if (orderManager.GameStarted) return; if (orderManager.GameStarted) return;
Ui.SelectedWidget = null; Ui.MouseFocusWidget = null;
Ui.KeyboardFocusWidget = null;
orderManager.LocalFrameNumber = 0; orderManager.LocalFrameNumber = 0;
orderManager.LastTickTime = Environment.TickCount; orderManager.LastTickTime = Environment.TickCount;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Widgets
if (ClickThrough || !Bounds.Contains(mi.Location)) if (ClickThrough || !Bounds.Contains(mi.Location))
return false; return false;
if (!Draggable || moving && (!TakeFocus(mi) || mi.Button != MouseButton.Left)) if (!Draggable || moving && (!TakeMouseFocus(mi) || mi.Button != MouseButton.Left))
return true; return true;
if (prevMouseLocation == null) if (prevMouseLocation == null)
@@ -44,7 +44,7 @@ namespace OpenRA.Widgets
{ {
case MouseInputEvent.Up: case MouseInputEvent.Up:
moving = false; moving = false;
LoseFocus(mi); YieldMouseFocus(mi);
break; break;
case MouseInputEvent.Down: case MouseInputEvent.Down:
moving = true; moving = true;

View File

@@ -83,10 +83,10 @@ namespace OpenRA.Widgets
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer)); Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
} }
public override bool LoseFocus(MouseInput mi) public override bool YieldMouseFocus(MouseInput mi)
{ {
Depressed = false; Depressed = false;
return base.LoseFocus(mi); return base.YieldMouseFocus(mi);
} }
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)
@@ -110,25 +110,25 @@ namespace OpenRA.Widgets
if (mi.Button != MouseButton.Left) if (mi.Button != MouseButton.Left)
return false; return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi))
return false; return false;
var disabled = IsDisabled(); var disabled = IsDisabled();
if (Focused && mi.Event == MouseInputEvent.Up && mi.MultiTapCount == 2) if (HasMouseFocus && mi.Event == MouseInputEvent.Up && mi.MultiTapCount == 2)
{ {
if (!disabled) if (!disabled)
{ {
OnDoubleClick(); OnDoubleClick();
return LoseFocus(mi); return YieldMouseFocus(mi);
} }
} }
// Only fire the onMouseUp event if we successfully lost focus, and were pressed // Only fire the onMouseUp event if we successfully lost focus, and were pressed
else if (Focused && mi.Event == MouseInputEvent.Up) else if (HasMouseFocus && mi.Event == MouseInputEvent.Up)
{ {
if (Depressed && !disabled) if (Depressed && !disabled)
OnMouseUp(mi); OnMouseUp(mi);
return LoseFocus(mi); return YieldMouseFocus(mi);
} }
if (mi.Event == MouseInputEvent.Down) if (mi.Event == MouseInputEvent.Down)
{ {
@@ -141,11 +141,11 @@ namespace OpenRA.Widgets
} }
else else
{ {
LoseFocus(mi); YieldMouseFocus(mi);
Sound.PlayNotification(null, "Sounds", "ClickDisabledSound", null); Sound.PlayNotification(null, "Sounds", "ClickDisabledSound", null);
} }
} }
else if (mi.Event == MouseInputEvent.Move && Focused) else if (mi.Event == MouseInputEvent.Move && HasMouseFocus)
Depressed = RenderBounds.Contains(mi.Location); Depressed = RenderBounds.Contains(mi.Location);
return Depressed; return Depressed;

View File

@@ -64,12 +64,12 @@ namespace OpenRA.Widgets
orderManager.IssueOrder(Order.Chat(teamChat, content)); orderManager.IssueOrder(Order.Chat(teamChat, content));
content = ""; content = "";
LoseFocus(); YieldKeyboardFocus();
return true; return true;
} }
else else
{ {
TakeFocus(new MouseInput()); TakeKeyboardFocus();
composing = true; composing = true;
teamChat = (Game.Settings.Game.TeamChatToggle && teamChat) teamChat = (Game.Settings.Game.TeamChatToggle && teamChat)
^ e.Modifiers.HasModifier(Modifiers.Shift); ^ e.Modifiers.HasModifier(Modifiers.Shift);
@@ -83,7 +83,7 @@ namespace OpenRA.Widgets
{ {
composing = false; composing = false;
content = ""; content = "";
LoseFocus(); YieldKeyboardFocus();
return true; return true;
} }
else if (e.KeyName == "backspace") else if (e.KeyName == "backspace")

View File

@@ -104,7 +104,7 @@ namespace OpenRA.Widgets
ButtonWidget.DrawBackground("button", downButtonRect, downDisabled, DownPressed, downHover, false); ButtonWidget.DrawBackground("button", downButtonRect, downDisabled, DownPressed, downHover, false);
if (thumbHeight > 0) if (thumbHeight > 0)
ButtonWidget.DrawBackground("scrollthumb", thumbRect, false, Focused && thumbHover, thumbHover, false); ButtonWidget.DrawBackground("scrollthumb", thumbRect, false, HasMouseFocus && thumbHover, thumbHover, false);
var upOffset = !UpPressed || upDisabled ? 4 : 4 + ButtonDepth; var upOffset = !UpPressed || upDisabled ? 4 : 4 + ButtonDepth;
var downOffset = !DownPressed || downDisabled ? 4 : 4 + ButtonDepth; var downOffset = !DownPressed || downDisabled ? 4 : 4 + ButtonDepth;
@@ -170,10 +170,10 @@ namespace OpenRA.Widgets
if (DownPressed) Scroll(-1); if (DownPressed) Scroll(-1);
} }
public override bool LoseFocus (MouseInput mi) public override bool YieldMouseFocus(MouseInput mi)
{ {
UpPressed = DownPressed = ThumbPressed = false; UpPressed = DownPressed = ThumbPressed = false;
return base.LoseFocus(mi); return base.YieldMouseFocus(mi);
} }
int2 lastMouseLocation; int2 lastMouseLocation;
@@ -194,14 +194,14 @@ namespace OpenRA.Widgets
if (mi.Button != MouseButton.Left) if (mi.Button != MouseButton.Left)
return false; return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi))
return false; return false;
if (!Focused) if (!HasMouseFocus)
return false; return false;
if (Focused && mi.Event == MouseInputEvent.Up) if (HasMouseFocus && mi.Event == MouseInputEvent.Up)
return LoseFocus(mi); return YieldMouseFocus(mi);
if (ThumbPressed && mi.Event == MouseInputEvent.Move) if (ThumbPressed && mi.Event == MouseInputEvent.Move)
{ {

View File

@@ -56,14 +56,14 @@ namespace OpenRA.Widgets
{ {
if (mi.Button != MouseButton.Left) return false; if (mi.Button != MouseButton.Left) return false;
if (IsDisabled()) return false; if (IsDisabled()) return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) return false; if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi)) return false;
if (!Focused) return false; if (!HasMouseFocus) return false;
switch(mi.Event) switch(mi.Event)
{ {
case MouseInputEvent.Up: case MouseInputEvent.Up:
isMoving = false; isMoving = false;
LoseFocus(mi); YieldMouseFocus(mi);
break; break;
case MouseInputEvent.Down: case MouseInputEvent.Down:

View File

@@ -52,11 +52,10 @@ namespace OpenRA.Widgets
VisualHeight = widget.VisualHeight; VisualHeight = widget.VisualHeight;
} }
public override bool LoseFocus(MouseInput mi) public override bool YieldKeyboardFocus()
{ {
OnLoseFocus(); OnLoseFocus();
var lose = base.LoseFocus(mi); return base.YieldKeyboardFocus();
return lose;
} }
public override bool HandleMouseInput(MouseInput mi) public override bool HandleMouseInput(MouseInput mi)
@@ -64,14 +63,11 @@ namespace OpenRA.Widgets
if (IsDisabled()) if (IsDisabled())
return false; return false;
if (mi.Event == MouseInputEvent.Move) if (mi.Event != MouseInputEvent.Down)
return false; return false;
// Lose focus if they click outside the box; return false so the next widget can grab this event // Attempt to take keyboard focus
if (mi.Event == MouseInputEvent.Down && !RenderBounds.Contains(mi.Location) && LoseFocus(mi)) if (!RenderBounds.Contains(mi.Location) || !TakeKeyboardFocus())
return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi))
return false; return false;
blinkCycle = 10; blinkCycle = 10;
@@ -89,7 +85,7 @@ namespace OpenRA.Widgets
var textSize = font.Measure(apparentText); var textSize = font.Measure(apparentText);
var start = RenderOrigin.X + LeftMargin; var start = RenderOrigin.X + LeftMargin;
if (textSize.X > Bounds.Width - LeftMargin - RightMargin && Focused) if (textSize.X > Bounds.Width - LeftMargin - RightMargin && HasKeyboardFocus)
start += Bounds.Width - LeftMargin - RightMargin - textSize.X; start += Bounds.Width - LeftMargin - RightMargin - textSize.X;
int minIndex = -1; int minIndex = -1;
@@ -107,13 +103,11 @@ namespace OpenRA.Widgets
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)
{ {
if (IsDisabled()) if (IsDisabled() || e.Event == KeyInputEvent.Up)
return false; return false;
if (e.Event == KeyInputEvent.Up) return false;
// Only take input if we are focused // Only take input if we are focused
if (!Focused) if (!HasKeyboardFocus)
return false; return false;
if ((e.KeyName == "return" || e.KeyName == "enter") && OnEnterKey()) if ((e.KeyName == "return" || e.KeyName == "enter") && OnEnterKey())
@@ -206,7 +200,7 @@ namespace OpenRA.Widgets
var disabled = IsDisabled(); var disabled = IsDisabled();
var state = disabled ? "textfield-disabled" : var state = disabled ? "textfield-disabled" :
Focused ? "textfield-focused" : HasKeyboardFocus ? "textfield-focused" :
Ui.MouseOverWidget == this ? "textfield-hover" : Ui.MouseOverWidget == this ? "textfield-hover" :
"textfield"; "textfield";
@@ -219,7 +213,7 @@ namespace OpenRA.Widgets
// Right align when editing and scissor when the text overflows // Right align when editing and scissor when the text overflows
if (textSize.X > Bounds.Width - LeftMargin - RightMargin) if (textSize.X > Bounds.Width - LeftMargin - RightMargin)
{ {
if (Focused) if (HasKeyboardFocus)
textPos += new int2(Bounds.Width - LeftMargin - RightMargin - textSize.X, 0); textPos += new int2(Bounds.Width - LeftMargin - RightMargin - textSize.X, 0);
Game.Renderer.EnableScissor(pos.X + LeftMargin, pos.Y, Game.Renderer.EnableScissor(pos.X + LeftMargin, pos.Y,
@@ -229,7 +223,7 @@ namespace OpenRA.Widgets
var color = disabled ? DisabledColor : TextColor; var color = disabled ? DisabledColor : TextColor;
font.DrawText(apparentText, textPos, color); font.DrawText(apparentText, textPos, color);
if (showCursor && Focused) if (showCursor && HasKeyboardFocus)
font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), Color.White); font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), Color.White);
if (textSize.X > Bounds.Width - LeftMargin - RightMargin) if (textSize.X > Bounds.Width - LeftMargin - RightMargin)

View File

@@ -72,10 +72,10 @@ namespace OpenRA.Widgets
public override string GetCursor(int2 pos) { return GetScrollCursor(this, Edge, pos); } public override string GetCursor(int2 pos) { return GetScrollCursor(this, Edge, pos); }
public override bool LoseFocus(MouseInput mi) public override bool YieldKeyboardFocus()
{ {
Keyboard = ScrollDirection.None; Keyboard = ScrollDirection.None;
return base.LoseFocus(mi); return base.YieldKeyboardFocus();
} }
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)

View File

@@ -23,7 +23,8 @@ namespace OpenRA.Widgets
static Stack<Widget> WindowList = new Stack<Widget>(); static Stack<Widget> WindowList = new Stack<Widget>();
public static Widget SelectedWidget; public static Widget MouseFocusWidget;
public static Widget KeyboardFocusWidget;
public static Widget MouseOverWidget; public static Widget MouseOverWidget;
public static void CloseWindow() public static void CloseWindow()
@@ -74,7 +75,7 @@ namespace OpenRA.Widgets
MouseOverWidget = null; MouseOverWidget = null;
bool handled = false; bool handled = false;
if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi)) if (MouseFocusWidget != null && MouseFocusWidget.HandleMouseInputOuter(mi))
handled = true; handled = true;
if (!handled && Root.HandleMouseInputOuter(mi)) if (!handled && Root.HandleMouseInputOuter(mi))
@@ -100,8 +101,8 @@ namespace OpenRA.Widgets
public static bool HandleKeyPress(KeyInput e) public static bool HandleKeyPress(KeyInput e)
{ {
if (SelectedWidget != null) if (KeyboardFocusWidget != null)
return SelectedWidget.HandleKeyPressOuter(e); return KeyboardFocusWidget.HandleKeyPressOuter(e);
if (Root.HandleKeyPressOuter(e)) if (Root.HandleKeyPressOuter(e))
return true; return true;
@@ -234,31 +235,46 @@ namespace OpenRA.Widgets
.Aggregate(EventBounds, Rectangle.Union); .Aggregate(EventBounds, Rectangle.Union);
} }
public bool Focused { get { return Ui.SelectedWidget == this; } } public bool HasMouseFocus { get { return Ui.MouseFocusWidget == this; } }
public bool HasKeyboardFocus { get { return Ui.KeyboardFocusWidget == this; } }
public virtual bool TakeFocus(MouseInput mi) public virtual bool TakeMouseFocus(MouseInput mi)
{ {
if (Focused) if (HasMouseFocus)
return true; return true;
if (Ui.SelectedWidget != null && !Ui.SelectedWidget.LoseFocus(mi)) if (Ui.MouseFocusWidget != null && !Ui.MouseFocusWidget.YieldMouseFocus(mi))
return false; return false;
Ui.SelectedWidget = this; Ui.MouseFocusWidget = this;
return true; return true;
} }
// Remove focus from this widget; return false if you don't want to give it up // Remove focus from this widget; return false if you don't want to give it up
public virtual bool LoseFocus(MouseInput mi) public virtual bool YieldMouseFocus(MouseInput mi)
{ {
// Some widgets may need to override focus depending on mouse click if (Ui.MouseFocusWidget == this)
return LoseFocus(); Ui.MouseFocusWidget = null;
return true;
} }
public virtual bool LoseFocus() public virtual bool TakeKeyboardFocus()
{ {
if (Ui.SelectedWidget == this) if (HasKeyboardFocus)
Ui.SelectedWidget = null; return true;
if (Ui.KeyboardFocusWidget != null && !Ui.KeyboardFocusWidget.YieldKeyboardFocus())
return false;
Ui.KeyboardFocusWidget = this;
return true;
}
public virtual bool YieldKeyboardFocus()
{
if (Ui.KeyboardFocusWidget == this)
Ui.KeyboardFocusWidget = null;
return true; return true;
} }
@@ -288,7 +304,7 @@ namespace OpenRA.Widgets
public bool HandleMouseInputOuter(MouseInput mi) public bool HandleMouseInputOuter(MouseInput mi)
{ {
// Are we able to handle this event? // Are we able to handle this event?
if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location)))) if (!(HasMouseFocus || (IsVisible() && GetEventBounds().Contains(mi.Location))))
return false; return false;
var oldMouseOver = Ui.MouseOverWidget; var oldMouseOver = Ui.MouseOverWidget;

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Widgets
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down) if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{ {
if (!TakeFocus(mi)) if (!TakeMouseFocus(mi))
return false; return false;
dragStart = dragEnd = xy; dragStart = dragEnd = xy;
@@ -75,13 +75,13 @@ namespace OpenRA.Widgets
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up) if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
{ {
if (UseClassicMouseStyle && Focused) if (UseClassicMouseStyle && HasMouseFocus)
{ {
//order units around //order units around
if (!HasBox && world.Selection.Actors.Any() && !MultiClick) if (!HasBox && world.Selection.Actors.Any() && !MultiClick)
{ {
ApplyOrders(world, xy, mi); ApplyOrders(world, xy, mi);
LoseFocus(mi); YieldMouseFocus(mi);
return true; return true;
} }
} }
@@ -108,7 +108,7 @@ namespace OpenRA.Widgets
} }
dragStart = dragEnd = xy; dragStart = dragEnd = xy;
LoseFocus(mi); YieldMouseFocus(mi);
} }
if (mi.Button == MouseButton.None && mi.Event == MouseInputEvent.Move) if (mi.Button == MouseButton.None && mi.Event == MouseInputEvent.Move)

View File

@@ -100,10 +100,10 @@ namespace OpenRA.Mods.Cnc.Widgets
?? base.GetCursor(pos); ?? base.GetCursor(pos);
} }
public override bool LoseFocus(MouseInput mi) public override bool YieldKeyboardFocus()
{ {
Keyboard = ScrollDirection.None; Keyboard = ScrollDirection.None;
return base.LoseFocus(mi); return base.YieldKeyboardFocus();
} }
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)

View File

@@ -208,10 +208,10 @@ namespace OpenRA.Mods.Cnc.Widgets
if (rightPressed) Scroll(-1); if (rightPressed) Scroll(-1);
} }
public override bool LoseFocus(MouseInput mi) public override bool YieldMouseFocus(MouseInput mi)
{ {
leftPressed = rightPressed = false; leftPressed = rightPressed = false;
return base.LoseFocus(mi); return base.YieldMouseFocus(mi);
} }
public override bool HandleMouseInput(MouseInput mi) public override bool HandleMouseInput(MouseInput mi)
@@ -231,14 +231,14 @@ namespace OpenRA.Mods.Cnc.Widgets
if (mi.Button != MouseButton.Left) if (mi.Button != MouseButton.Left)
return true; return true;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi))
return true; return true;
if (!Focused) if (!HasMouseFocus)
return true; return true;
if (Focused && mi.Event == MouseInputEvent.Up) if (HasMouseFocus && mi.Event == MouseInputEvent.Up)
return LoseFocus(mi); return YieldMouseFocus(mi);
leftPressed = leftButtonRect.Contains(mi.Location); leftPressed = leftButtonRect.Contains(mi.Location);
rightPressed = rightButtonRect.Contains(mi.Location); rightPressed = rightButtonRect.Contains(mi.Location);

View File

@@ -165,16 +165,16 @@ namespace OpenRA.Mods.RA.Widgets
{ {
if (mi.Button != MouseButton.Left) if (mi.Button != MouseButton.Left)
return false; return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi))
return false; return false;
if (!Focused) if (!HasMouseFocus)
return false; return false;
switch (mi.Event) switch (mi.Event)
{ {
case MouseInputEvent.Up: case MouseInputEvent.Up:
isMoving = false; isMoving = false;
LoseFocus(mi); YieldMouseFocus(mi);
break; break;
case MouseInputEvent.Down: case MouseInputEvent.Down:

View File

@@ -104,14 +104,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ChatText.Text = ""; ChatText.Text = "";
ChatOverlay.Visible = false; ChatOverlay.Visible = false;
ChatChrome.Visible = true; ChatChrome.Visible = true;
ChatText.TakeFocus(new MouseInput()); ChatText.TakeKeyboardFocus();
} }
public void CloseChat() public void CloseChat()
{ {
ChatOverlay.Visible = true; ChatOverlay.Visible = true;
ChatChrome.Visible = false; ChatChrome.Visible = false;
ChatText.LoseFocus(); ChatText.YieldKeyboardFocus();
} }
public bool IsOpen { get { return ChatChrome.IsVisible(); } } public bool IsOpen { get { return ChatChrome.IsVisible(); } }

View File

@@ -215,23 +215,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
name.IsDisabled = () => orderManager.LocalClient.IsReady; name.IsDisabled = () => orderManager.LocalClient.IsReady;
name.Text = c.Name; name.Text = c.Name;
name.OnEnterKey = () => name.OnLoseFocus = () =>
{ {
name.Text = name.Text.Trim(); name.Text = name.Text.Trim();
if (name.Text.Length == 0) if (name.Text.Length == 0)
name.Text = c.Name; name.Text = c.Name;
name.LoseFocus();
if (name.Text == c.Name) if (name.Text == c.Name)
return true; return;
orderManager.IssueOrder(Order.Command("name " + name.Text)); orderManager.IssueOrder(Order.Command("name " + name.Text));
Game.Settings.Player.Name = name.Text; Game.Settings.Player.Name = name.Text;
Game.Settings.Save(); Game.Settings.Save();
return true;
}; };
name.OnLoseFocus = () => name.OnEnterKey(); name.OnEnterKey = () => { name.YieldKeyboardFocus(); return true; };
} }
public static void SetupNameWidget(Widget parent, Session.Slot s, Session.Client c) public static void SetupNameWidget(Widget parent, Session.Slot s, Session.Client c)

View File

@@ -43,13 +43,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
name.OnLoseFocus = () => name.OnLoseFocus = () =>
{ {
name.Text = name.Text.Trim(); name.Text = name.Text.Trim();
if (name.Text.Length == 0) if (name.Text.Length == 0)
name.Text = Game.Settings.Player.Name; name.Text = Game.Settings.Player.Name;
else else
Game.Settings.Player.Name = name.Text; Game.Settings.Player.Name = name.Text;
}; };
name.OnEnterKey = () => { name.LoseFocus(); return true; }; name.OnEnterKey = () => { name.YieldKeyboardFocus(); return true; };
var edgescrollCheckbox = general.Get<CheckboxWidget>("EDGE_SCROLL"); var edgescrollCheckbox = general.Get<CheckboxWidget>("EDGE_SCROLL");
edgescrollCheckbox.IsChecked = () => Game.Settings.Game.ViewportEdgeScroll; edgescrollCheckbox.IsChecked = () => Game.Settings.Game.ViewportEdgeScroll;
@@ -315,7 +314,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var textBox = keyWidget.Get<TextFieldWidget>("HOTKEY"); var textBox = keyWidget.Get<TextFieldWidget>("HOTKEY");
textBox.Text = getValue(); textBox.Text = getValue();
textBox.OnLoseFocus = () => textBox.OnLoseFocus = () =>
{ {
textBox.Text.Trim(); textBox.Text.Trim();
@@ -324,8 +322,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
else else
setValue(textBox.Text); setValue(textBox.Text);
}; };
textBox.OnEnterKey = () => { textBox.YieldKeyboardFocus(); return true; };
textBox.OnEnterKey = () => { textBox.LoseFocus(); return true; };
} }
public static bool ShowRendererDropdown(DropDownButtonWidget dropdown, GraphicSettings s) public static bool ShowRendererDropdown(DropDownButtonWidget dropdown, GraphicSettings s)