Skip to content

Commit

Permalink
v0.0.2; fix Npp 8.6.1+ Ctrl+C/X bug; PopupDialog
Browse files Browse the repository at this point in the history
Release version 0.0.2.
FIX: Fix bug introduced in Notepad++ 8.6.1 where
    `Ctrl+C` and `Ctrl+X` would not work
    in the text fields of forms.
ADD: new PopupDialog to illustrate differences
    between modal and modeless dialogs.
  • Loading branch information
molsonkiko committed Feb 7, 2024
1 parent 9eaefbf commit c6e3ffe
Show file tree
Hide file tree
Showing 19 changed files with 477 additions and 102 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Change Log
All [notable changes](#001---2024-01-13) to this project will be documented in this file.
All [notable changes](#002---2024-02-06) to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
Expand All @@ -19,12 +19,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### To Be Fixed

- Closing HTML/XML tags works inconsistently in Notepad++ v7.3.3.
- Avoid plugin crash when too-large int values are entered in the selection-remembering form.

## [0.0.2] - (UNRELEASED) YYYY-MM-DD
## [0.0.2] - 2024-02-06

### Added

1. Ported over (from kbilsted's old template) the [ToolsForMaintainersOfTheProjectTemplate](/ToolsForMaintainersOfTheProjectTemplate/) folder for updating some of the [PluginInfrastructure](/NppCSharpPluginPack/PluginInfrastructure/) files to stay up to date with Notepad++.
2. Added new [PopupDialog form](/docs/README.md#popup-dialog), which demonstrates how to configure a pop-up dialog that has select-able fields like textboxes or buttons.

### Changed

Expand All @@ -34,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

1. [TestRunner.cs](/NppCSharpPluginPack/Tests/TestRunner.cs) now restores clipboard text after tests.
2. Link label text and background now correctly switches back to defaults when going from a dark theme to default styles.
3. Fix bug where running tests multiple times in a single Notepad++ session causes the user interface tests to fail.
3. Fix bug where running tests multiple times in a single Notepad++ session causes the [user interface tests](/docs/README.md#running-tests) to fail.
4. [Fix bug introduced in Notepad++ 8.6.1 where `Ctrl+C` and `Ctrl+X` would not work in the text fields of forms.](/docs/README.md#registering-and-unregistering-forms-with-nppm_modelessdialog)

## [0.0.1] - 2024-01-13

Expand Down
1 change: 1 addition & 0 deletions NppCSharpPluginPack/Forms/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public partial class AboutForm : Form
public AboutForm()
{
InitializeComponent();
NppFormHelper.RegisterFormIfModeless(this, true);
FormStyle.ApplyStyle(this, Main.settings.use_npp_styling);
ThanksWowLinkLabel.LinkColor = ThanksWowLinkLabel.ForeColor; // hidden!
Title.Text = Title.Text.Replace("X.Y.Z.A", Npp.AssemblyVersionString());
Expand Down
100 changes: 51 additions & 49 deletions NppCSharpPluginPack/Forms/DarkModeTestForm.Designer.cs

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

7 changes: 7 additions & 0 deletions NppCSharpPluginPack/Forms/DarkModeTestForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class DarkModeTestForm : Form
public DarkModeTestForm(SelectionRememberingForm selectionRememberingForm)
{
InitializeComponent();
NppFormHelper.RegisterFormIfModeless(this, false);
this.selectionRememberingForm = selectionRememberingForm;
selectionRememberingForm.AddOwnedForm(this);
FormStyle.ApplyStyle(this, Main.settings.use_npp_styling);
Expand Down Expand Up @@ -39,5 +40,11 @@ public void GrabFocus()
Show();
textBox1.Focus();
}

private void ShowPopupDialogButton_Click(object sender, System.EventArgs e)
{
using (var popupDialog = new PopupDialog())
popupDialog.ShowDialog();
}
}
}
11 changes: 1 addition & 10 deletions NppCSharpPluginPack/Forms/DarkModeTestForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADw
CgAAAk1TRnQBSQFMAgEBAwEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CgAAAk1TRnQBSQFMAgEBAwEAASgBAAEoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down Expand Up @@ -183,13 +183,4 @@
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
72 changes: 42 additions & 30 deletions NppCSharpPluginPack/Forms/NppFormHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ public static void TextBoxKeyPressHandler(object sender, KeyPressEventArgs e)
}

/// <summary>
/// CALL THIS IN YOUR KeyUp HANDLER FOR ALL CONTROLS<br></br>
/// CALL THIS IN YOUR KeyUp HANDLER FOR ALL CONTROLS (but only add to the form itself *IF NOT isModal*)<br></br>
/// Enter presses button,<br></br>
/// escape focuses editor (or closes if this.IsModal),<br></br>
/// tab goes through controls,<br></br>
/// shift-tab -> go through controls backward<br></br>
/// Ctrl+V pastes text into text boxes and combo boxes
/// escape focuses editor (or closes if isModal),<br></br>
/// Ctrl+V pastes text into text boxes and combo boxes<br></br>
/// if isModal:<br></br>
/// - tab goes through controls,<br></br>
/// - shift-tab -> go through controls backward<br></br>
/// </summary>
/// <param name="form"></param>
/// <param name="isModal">if true, this blocks the parent application until closed. THIS IS ONLY TRUE OF POP-UP DIALOGS</param>
Expand All @@ -65,7 +66,7 @@ public static void GenericKeyUpHandler(Form form, object sender, KeyEventArgs e,
Npp.editor.GrabFocus();
}
// Tab -> go through controls, Shift+Tab -> go through controls backward
else if (e.KeyCode == Keys.Tab)
else if (e.KeyCode == Keys.Tab && isModal)
{
GenericTabNavigationHandler(form, sender, e);
}
Expand All @@ -91,32 +92,43 @@ public static void GenericTabNavigationHandler(Form form, object sender, KeyEven
e.Handled = true;
}

///// <summary>
///// <i><b>THIS IS CURRENTLY A NO-OP! Don't uncomment it, because it will mess with tab navigation.</b></i><br></br>
///// CALL THIS METHOD IN THE INITIALIZER<br></br>
///// When this form is initialized, *if it is a modeless dialog* (i.e., !isModal; the form does not block the parent application until closed)<br></br>
///// this will call Notepad++ with the NPPM_MODELESSDIALOG message to register the form.
///// </summary>
///// <param name="isModal">if true, this blocks the parent application until closed. THIS IS ONLY TRUE OF POP-UP DIALOGS</param>
//public static void RegisterFormIfModeless(Form form, bool isModal)
//{
// if (!isModal)
// Npp.notepad.AddModelessDialog(form.Handle);
//}
/// <summary>
/// CALL THIS IN YOUR Dispose(bool disposing) METHOD, INSIDE OF THE ".Designer.cs" FILE<br></br>
/// When this form is initialized, *if it is a modeless dialog* (i.e., !isModal; the form does not block the parent application until closed)<br></br>
/// this will call Notepad++ with the NPPM_MODELESSDIALOG message to register the form.
/// <strong>VERY IMPORTANT: in your Designer.cs files, in the part where it says this.Controls.Add(nameOfControl),
/// you need to make sure the controls are added in tabstop order.</strong><br></br>
/// This is because the order in which the controls are added controls tab order.<br></br>
/// For example, if you want to go through your controls in the order<br></br>
/// 1. FooButton<br></br>
/// 2. BarTextBox<br></br>
/// 3. BazCheckBox<br></br>
/// You must go to your Designer.cs file and make sure that the Form adds the controls in this order:<br></br>
/// <code>
/// this.Controls.Add(this.FooButton);
/// this.Controls.Add(this.BarTextBox);
/// this.Controls.Add(this.BazCheckBox);
/// </code>
/// </summary>
/// <param name="isModal">if true, this blocks the parent application until closed. THIS IS ONLY TRUE OF POP-UP DIALOGS</param>
public static void RegisterFormIfModeless(Form form, bool isModal)
{
if (!isModal)
Npp.notepad.AddModelessDialog(form.Handle);
}



///// <summary>
///// <i><b>THIS IS CURRENTLY A NO-OP</b></i><br></br>
///// CALL THIS IN YOUR Dispose(bool disposing) METHOD, INSIDE OF THE ".Designer.cs" FILE<br></br>
///// If this was a modeless dialog (i.e., !isModal; a dialog that does not block Notepad++ while open),<br></br>
///// call Notepad++ with the NPPM_MODELESSDIALOG message to unregister the form.
///// </summary>
///// <param name="isModal">if true, this blocks the parent application until closed. THIS IS ONLY TRUE OF POP-UP DIALOGS</param>
//public static void UnregisterFormIfModeless(Form form, bool isModal)
//{
// if (!form.IsDisposed && !isModal)
// Npp.notepad.RemoveModelessDialog(form.Handle);
//}
/// <summary>
/// CALL THIS IN YOUR Dispose(bool disposing) METHOD, INSIDE OF THE ".Designer.cs" FILE<br></br>
/// If this was a modeless dialog (i.e., !isModal; a dialog that does not block Notepad++ while open),<br></br>
/// call Notepad++ with the NPPM_MODELESSDIALOG message to unregister the form.
/// </summary>
/// <param name="isModal">if true, this blocks the parent application until closed. THIS IS ONLY TRUE OF POP-UP DIALOGS</param>
public static void UnregisterFormIfModeless(Form form, bool isModal)
{
if (!form.IsDisposed && !isModal)
Npp.notepad.RemoveModelessDialog(form.Handle);
}
}
}
Loading

0 comments on commit c6e3ffe

Please sign in to comment.