Hi
>From http://www.mono-project.com/SVN#Making_patches :
Mouse Click Event was missing in SWF implementation, here it is a
patch to fix that
The second patch add the standar context menu to Masked text box, the
same is also missing in combobox stuff(combo, toolstripcombo
.........).
it is released under MIT/X11 or what ever you want.

-- 
 Cordially.

 Small Eric Quotations of the days:
 ---------------------------------------------------------------------------
 I have no special talents. I am only passionately curious
Index: MaskedTextBox.cs
===================================================================
--- MaskedTextBox.cs	(révision 144930)
+++ MaskedTextBox.cs	(copie de travail)
@@ -62,6 +62,13 @@
 		private Type validating_type;
 		private bool is_empty_mask;
 		private bool setting_text;
+		private ContextMenu menu;
+		private MenuItem undo;
+		private MenuItem cut;
+		private MenuItem copy;
+		private MenuItem paste;
+		private MenuItem delete;
+		private MenuItem select_all;
 #endregion
 
 #region Events
@@ -151,9 +158,99 @@
 			cut_copy_mask_format = MaskFormat.IncludeLiterals;
 			insert_key_overwriting = false;
 			UpdateVisibleText ();
+			
+
+			undo = new MenuItem(Locale.GetText("&Undo"));
+			cut = new MenuItem(Locale.GetText("Cu&t"));
+			copy = new MenuItem(Locale.GetText("&Copy"));
+			paste = new MenuItem(Locale.GetText("&Paste"));
+			delete = new MenuItem(Locale.GetText("&Delete"));
+			select_all = new MenuItem(Locale.GetText("Select &All"));
+
+			menu = new ContextMenu(new MenuItem[] { undo, new MenuItem("-"), cut, copy, paste, delete, new MenuItem("-"), select_all});
+			ContextMenu = menu;
+
+			menu.Popup += new EventHandler(menu_Popup);
+			undo.Click += new EventHandler(undo_Click);
+			cut.Click += new EventHandler(cut_Click);
+			copy.Click += new EventHandler(copy_Click);
+			paste.Click += new EventHandler(paste_Click);
+			delete.Click += new EventHandler(delete_Click);
+			select_all.Click += new EventHandler(select_all_Click);
+
 		}
 #endregion
 
+#region Private Methods
+
+		internal override ContextMenu ContextMenuInternal {
+			get {
+				ContextMenu res = base.ContextMenuInternal;
+				if (res == menu)
+					return null;
+				return res;
+			}
+			set {
+				base.ContextMenuInternal = value;
+			}
+		}
+
+		internal void RestoreContextMenu ()
+		{
+			ContextMenuInternal = menu;
+		}
+
+		private void menu_Popup(object sender, EventArgs e) {
+			if (SelectionLength == 0) {
+				cut.Enabled = false;
+				copy.Enabled = false;
+			} else {
+				cut.Enabled = true;
+				copy.Enabled = true;
+			}
+
+			if (SelectionLength == TextLength) {
+				select_all.Enabled = false;
+			} else {
+				select_all.Enabled = true;
+			}
+
+			if (!CanUndo) {
+				undo.Enabled = false;
+			} else {
+				undo.Enabled = true;
+			}
+
+			if (ReadOnly) {
+				undo.Enabled = cut.Enabled = paste.Enabled = delete.Enabled = false;
+			}
+		}
+
+		private void undo_Click(object sender, EventArgs e) {
+			Undo();
+		}
+
+		private void cut_Click(object sender, EventArgs e) {
+			Cut();
+		}
+
+		private void copy_Click(object sender, EventArgs e) {
+			Copy();
+		}
+
+		private void paste_Click(object sender, EventArgs e) {
+			Paste();
+		}
+
+		private void delete_Click(object sender, EventArgs e) {
+			SelectedText = string.Empty;
+		}
+
+		private void select_all_Click(object sender, EventArgs e) {
+			SelectAll();
+		}
+#endregion	// Private Methods
+
 #region Public and protected methods
 		[EditorBrowsable (EditorBrowsableState.Never)]
 		public new void ClearUndo ()
Index: Button.cs
===================================================================
--- Button.cs	(révision 144930)
+++ Button.cs	(copie de travail)
@@ -128,6 +128,11 @@
 			base.OnMouseUp (mevent);
 		}
 
+		protected override void OnMouseClick(MouseEventArgs mevent)
+		{
+			base.OnMouseClick(mevent);
+		}
+
 #if NET_2_0
 		protected override void OnTextChanged (EventArgs e)
 		{
Index: ButtonBase.cs
===================================================================
--- ButtonBase.cs	(révision 144930)
+++ ButtonBase.cs	(copie de travail)
@@ -632,6 +632,7 @@
 				if (ClientRectangle.Contains (mevent.Location))
 					if (!ValidationFailed)
 						OnClick (EventArgs.Empty);
+					        OnMouseClick(mevent);
 			}
 			
 			base.OnMouseUp (mevent);
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to