Re: [PATCH] For MouseClick Event in SWF
Petit Eric <[email protected]>
| Newsgroups | gmane.comp.gnome.winforms |
|---|---|
| Message-ID | <[email protected]> |
Finally, here it an all in one patch, review from your comments, for the MouseClick Event and the standard context menu for the MaskedTextBox. 2009/10/28 Petit Eric <[email protected]> > oki , weired, but i will try to do it; > Effort are duplicate, your comment are really nice and right, i need to > took them for next patch, but most of them are to delete some extra data in > the patch, after you will review a second time etc :-) > > 2009/10/28 Carlos Alberto Cortez <[email protected]> > > No dude, you need to do it directly you. That's the usual process all the >> contributors do: they send a patch, then the maintainer suggests some >> changes, then the contributor applies those changes. >> >> >> Carlos. >> >> 2009/10/27 Petit Eric <[email protected]> >> >>> Hum, could you directly modify it ! ? >>> >>> >>> >>> 2009/10/27 Carlos Alberto Cortez <[email protected]> >>> >>>> Comments below: >>>> >>>> - protected override void OnMouseUp (MouseEventArgs >>>> mevent) >>>> - { >>>> - base.OnMouseUp (mevent); >>>> - } >>>> + protected override void OnMouseUp(MouseEventArgs mevent) >>>> + { >>>> + base.OnMouseUp(mevent); >>>> + } >>>> >>>> + protected override void OnMouseClick(MouseEventArgs mevent) >>>> + { >>>> + base.OnMouseClick(mevent); >>>> + } >>>> + >>>> >>>> Be careful to *not* send changes including style modifications. >>>> >>>> + protected override void OnMouseClick(MouseEventArgs mevent) >>>> + { >>>> + if ((mevent.Button & MouseButtons.Left) != 0) >>>> + { >>>> + is_pressed = true; >>>> + Invalidate(); >>>> + } >>>> + >>>> + base.OnMouseClick(mevent); >>>> + } >>>> + >>>> >>>> In .Net ButtonBase is not overriding this method, so we can't do that. >>>> Moreover, we don't need to do this. >>>> >>>> - if (!ValidationFailed) >>>> - OnClick >>>> (EventArgs.Empty); >>>> + if (!ValidationFailed) >>>> + { >>>> + OnClick(EventArgs.Empty); >>>> + OnMouseClick(mevent); >>>> + } >>>> >>>> This is fine, and this is the only bit we need to fix the issue. Just >>>> follow the coding guidelines: http://www.mono-project.com/Guidelines >>>> >>>> Re-send me the patch when it's done ;-) >>>> >>>> Carlos. >>>> >>>> >>>> 2009/10/27 Carlos Alberto Cortez <[email protected]> >>>> >>>>> Hey, >>>>> >>>>> >>>>> >>>>> I will review the patch later, but there's no need to send the patch to >>>>> the mono develop list, since the change is related to windows.forms. Also, >>>>> the mono-patches list is used to receive/catch the changes in svn. Next time >>>>> send the patch to the winforms list, please. >>>>> >>>>> Carlos. >>>>> >>>>> 2009/10/27 Petit Eric <[email protected]> >>>>> >>>>> Hi >>>>>> Mouse Click Event was missing in SWF implementation, here it is a >>>>>> patch to fix that [?] >>>>>> it is released under MIT/X11 or what ever you want. >>>>>> Carlos, if you apply the patch, could you think about my "coding for >>>>>> fun" and add my nickname in the log ?[?] >>>>>> -- >>>>>> Cordially. >>>>>> >>>>>> Small Eric Quotations of the days: >>>>>> --------------------------------------------------------------------------- >>>>>> >>>>>> I have no special talents. I am only passionately curious >>>>>> >>>>> >>>>> >>>> >>> >>> >>> -- >>> Cordially. >>> >>> Small Eric Quotations of the days: >>> --------------------------------------------------------------------------- >>> >>> I have no special talents. I am only passionately curious >>> >> >> > > > -- > Cordially. > > Small Eric Quotations of the days: > --------------------------------------------------------------------------- > > I have no special talents. I am only passionately curious > -- Cordially. Small Eric Quotations of the days: --------------------------------------------------------------------------- I have no special talents. I am only passionately curious Sent from Paris, France _______________________________________________ Mono-winforms-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-winforms-list
329.png
(image/png, 628 B) - not displayed
330.gif
(image/gif, 96 B) - not displayed
MouseClickEvAndCtxMenu4MaskedTxtBox.patch
(application/octet-stream, 3.7 KB)
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: 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: 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);