Browse Source

Focus and mouse events handlers enhanced. Closes #517

BDisp 5 years ago
parent
commit
608ab1c0c6
2 changed files with 14 additions and 4 deletions
  1. 12 2
      Terminal.Gui/Views/ComboBox.cs
  2. 2 2
      Terminal.Gui/Views/ScrollView.cs

+ 12 - 2
Terminal.Gui/Views/ComboBox.cs

@@ -40,7 +40,7 @@ namespace Terminal.Gui {
 		/// <param name="y">The y coordinate</param>
 		/// <param name="w">The width</param>
 		/// <param name="h">The height</param>
-		/// <param name="source">Auto completetion source</param>
+		/// <param name="source">Auto completion source</param>
 		public ComboBox(int x, int y, int w, int h, IList<string> source)
 		{
 			listsource = new List<string>(source);
@@ -81,11 +81,21 @@ namespace Terminal.Gui {
 					search.ColorScheme = Colors.Menu;
 			};
 
+			search.MouseClick += Search_MouseClick;
+
 			this.Add(listview);
 			this.Add(search);
 			this.SetFocus(search);
 		}
 
+		private void Search_MouseClick (object sender, MouseEventEventArgs e)
+		{
+			if (e.mouseEvent.Flags != MouseFlags.Button1Clicked)
+				return;
+
+			SuperView.SetFocus (((View)sender));
+		}
+
 		///<inheritdoc cref="OnEnter"/>
 		public override bool OnEnter ()
 		{
@@ -156,7 +166,7 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		/// The currenlty selected list item
+		/// The currently selected list item
 		/// </summary>
 		public ustring Text
 		{

+ 2 - 2
Terminal.Gui/Views/ScrollView.cs

@@ -327,12 +327,12 @@ namespace Terminal.Gui {
 			contentView.Add (view);
 		}
 
-		void View_MouseLeave (object sender, MouseEvent e)
+		void View_MouseLeave (object sender, MouseEventEventArgs e)
 		{
 			Application.UngrabMouse ();
 		}
 
-		void View_MouseEnter (object sender, MouseEvent e)
+		void View_MouseEnter (object sender, MouseEventEventArgs e)
 		{
 			Application.GrabMouse (this);
 		}