Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendBox.cs & NavigationControl.cs: implement triple click to select all text in textbox. #15

Merged
merged 1 commit into from Jun 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions ZeroKLobby/MicroLobby/SendBox.cs
Expand Up @@ -32,6 +32,7 @@ public SendBox()
this.BackColor = Program.Conf.BgColor;
this.ForeColor = Program.Conf.TextColor;
this.KeyDown += SendBox_KeyDown;
this.MouseDown += SendBox_MouseDown;
}

protected override void OnKeyPress(KeyPressEventArgs e)
Expand Down Expand Up @@ -259,5 +260,18 @@ private void SendBox_KeyDown(object sender, KeyEventArgs e)
else if (e.Control & e.KeyCode == Keys.B)
InsertColorCharacter("02", "12");//blue on light cyan
}

private int clickCount = 0;
private long lastClick = 0;
private int systemDoubleClickTime = SystemInformation.DoubleClickTime * 10000;
private void SendBox_MouseDown(object sender, EventArgs e)
{ //reference: http://stackoverflow.com/questions/5014825/triple-mouse-click-in-c
//10,000 ticks is a milisecond, therefore 2,000,000 ticks is 200milisecond . http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx
//double click time: http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.doubleclicktime(v=vs.110).aspx
if (DateTime.Now.Ticks - lastClick <= systemDoubleClickTime) clickCount = clickCount + 1;
else clickCount = 1;
if (clickCount%3 == 0) SelectAll(); //select all text when triple click
lastClick = DateTime.Now.Ticks;
}
}
}
3 changes: 1 addition & 2 deletions ZeroKLobby/NavigationControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions ZeroKLobby/NavigationControl.cs
Expand Up @@ -42,7 +42,6 @@ public partial class NavigationControl: UserControl
readonly Dictionary<INavigatable, string> lastTabPaths = new Dictionary<INavigatable, string>();
public ChatTab ChatTab { get { return chatTab; } }
public static NavigationControl Instance { get; private set; }
bool selectURLtextboxAll = false;

public string Path {
get { return CurrentPage != null ? CurrentPage.ToString() : string.Empty; }
Expand Down Expand Up @@ -330,17 +329,6 @@ public void AddToHistoryStack(String finalURL, String firstURL, Object obj)
}
}

private void urlBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (!selectURLtextboxAll) { urlBox.SelectAll(); }
selectURLtextboxAll = !selectURLtextboxAll;
}

private void urlBox_Enter(object sender, EventArgs e)
{
selectURLtextboxAll = false;
}

private void logoutButton_Click(object sender, EventArgs e)
{
Program.TasClient.Disconnect();
Expand All @@ -352,5 +340,19 @@ private void isBusyTimer_Tick(object sender, EventArgs e)
{
isBusyIcon.Visible = CurrentNavigatable.IsBusy;
}

private int clickCount = 0;
private long lastClick = 0;
private int systemDoubleClickTime = SystemInformation.DoubleClickTime * 10000;
private void urlBox_MouseDown(object sender, MouseEventArgs e)
{
//reference: http://stackoverflow.com/questions/5014825/triple-mouse-click-in-c
//10,000 ticks is a milisecond, therefore 2,000,000 ticks is 200milisecond . http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx
//double click time: http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.doubleclicktime(v=vs.110).aspx
if (DateTime.Now.Ticks - lastClick <= systemDoubleClickTime) clickCount = clickCount + 1;
else clickCount = 1;
if (clickCount % 3 == 0) urlBox.SelectAll(); //select all text when triple click
lastClick = DateTime.Now.Ticks;
}
}
}