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

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

View File

@@ -104,14 +104,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ChatText.Text = "";
ChatOverlay.Visible = false;
ChatChrome.Visible = true;
ChatText.TakeFocus(new MouseInput());
ChatText.TakeKeyboardFocus();
}
public void CloseChat()
{
ChatOverlay.Visible = true;
ChatChrome.Visible = false;
ChatText.LoseFocus();
ChatText.YieldKeyboardFocus();
}
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.Text = c.Name;
name.OnEnterKey = () =>
name.OnLoseFocus = () =>
{
name.Text = name.Text.Trim();
if (name.Text.Length == 0)
name.Text = c.Name;
name.LoseFocus();
if (name.Text == c.Name)
return true;
return;
orderManager.IssueOrder(Order.Command("name " + name.Text));
Game.Settings.Player.Name = name.Text;
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)

View File

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