Blink the KeyboardEntryWidget on focus.

This commit is contained in:
Paul Chote
2013-10-22 19:45:00 +13:00
parent 359d71b5db
commit b31daf23ca

View File

@@ -59,6 +59,8 @@ namespace OpenRA.Widgets
if (!RenderBounds.Contains(mi.Location) || !TakeKeyboardFocus())
return false;
blinkCycle = 15;
return true;
}
@@ -83,6 +85,18 @@ namespace OpenRA.Widgets
return true;
}
protected int blinkCycle = 15;
protected bool showEntry = true;
public override void Tick()
{
if (HasKeyboardFocus && --blinkCycle <= 0)
{
blinkCycle = 15;
showEntry ^= true;
}
}
public override void Draw()
{
var apparentText = Key.DisplayString();
@@ -100,6 +114,10 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel(state, RenderBounds);
// Blink the current entry to indicate focus
if (HasKeyboardFocus && !showEntry)
return;
// Inset text by the margin and center vertically
var textPos = pos + new int2(LeftMargin, (Bounds.Height - textSize.Y) / 2 - VisualHeight);