InputWidget - hide caret, increment even on duplicate (just don't overwrite anything), don't highlight text on focus

This commit is contained in:
andres.delikat 2011-07-09 21:55:14 +00:00
parent 43c9cd8047
commit 9419e02091
1 changed files with 16 additions and 5 deletions

View File

@ -2,6 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
@ -16,11 +17,21 @@ namespace BizHawk.MultiClient
string[] Bindings = new string[4]; string[] Bindings = new string[4];
string wasPressed = ""; string wasPressed = "";
[DllImport("user32")]
private static extern bool HideCaret(IntPtr hWnd);
public InputWidget() public InputWidget()
{ {
this.ContextMenu = new ContextMenu(); this.ContextMenu = new ContextMenu();
this.timer.Tick += new System.EventHandler(this.Timer_Tick); this.timer.Tick += new System.EventHandler(this.Timer_Tick);
InitializeBindings(); InitializeBindings();
// this.OnGotFocus
}
protected override void OnMouseClick(MouseEventArgs e)
{
HideCaret(this.Handle);
base.OnMouseClick(e);
} }
public InputWidget(int maxBindings) public InputWidget(int maxBindings)
@ -44,7 +55,6 @@ namespace BizHawk.MultiClient
{ {
pos = 0; pos = 0;
timer.Start(); timer.Start();
base.OnEnter(e);
Input.Update(); Input.Update();
wasPressed = Input.GetPressedKey(); wasPressed = Input.GetPressedKey();
} }
@ -81,12 +91,12 @@ namespace BizHawk.MultiClient
if (!IsDuplicate(TempBindingStr)) if (!IsDuplicate(TempBindingStr))
{ {
Bindings[pos] = TempBindingStr; Bindings[pos] = TempBindingStr;
}
wasPressed = TempBindingStr; wasPressed = TempBindingStr;
UpdateLabel(); UpdateLabel();
Increment(); Increment();
} }
} }
}
public bool IsDuplicate(string binding) public bool IsDuplicate(string binding)
{ {
@ -182,7 +192,8 @@ namespace BizHawk.MultiClient
protected override void OnGotFocus(EventArgs e) protected override void OnGotFocus(EventArgs e)
{ {
base.OnGotFocus(e); //base.OnGotFocus(e);
HideCaret(this.Handle);
BackColor = Color.Pink; BackColor = Color.Pink;
} }