Skip to content

Commit

Permalink
Fix images in the input text box. (#1592)
Browse files Browse the repository at this point in the history
* Fix #1590.

* Improve text input paste detection.

* Add a comment about Wine.

* Fix a typo.
  • Loading branch information
VladiStep authored Jan 1, 2024
1 parent 979db25 commit 9e44877
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 106 deletions.
200 changes: 97 additions & 103 deletions UndertaleModTool/Windows/TextInput.Designer.cs

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

20 changes: 17 additions & 3 deletions UndertaleModTool/Windows/TextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TextInput(string message, string title, string defaultValue, bool allowMu
label1.Text = message;
richTextBox1.Multiline = AllowMultiline;
richTextBox1.DetectUrls = false;
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.UIFonts; //prevents the bug with Japanese characters
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.UIFonts; // Prevents the bug with Japanese characters
richTextBox1.ReadOnly = readOnly;

label1.AutoSize = false;
Expand All @@ -100,7 +100,7 @@ public TextInput(string message, string title, string defaultValue, bool allowMu

private void TextInput_Load(object sender, EventArgs e)
{
richTextBox1.Clear(); //remove "Input text here"
richTextBox1.Clear(); // Remove "Input text here"

if (DefaultValue.Length > 0)
{
Expand All @@ -111,14 +111,28 @@ private void TextInput_Load(object sender, EventArgs e)

if (richTextBox1.ReadOnly)
{
richTextBox1.BackColor = TextBoxBGColor; //restore color to default one.
richTextBox1.BackColor = TextBoxBGColor; // Restore color to default one.
richTextBox1.ContextMenuStrip = textCopyMenu;
}
}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
// Prevent image pasting
// Based on this - https://stackoverflow.com/questions/13703083/prevent-images-in-rich-text-box
// TODO: What if you use a different key combination when you run the app from Wine on Linux?
if (e.Control && e.KeyCode == Keys.V
|| e.Shift && e.KeyCode == Keys.Insert)
{
if (Clipboard.ContainsText())
richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Text));

e.Handled = true;
}
}

private void button1_Click(object sender, EventArgs e)
{
Expand Down

0 comments on commit 9e44877

Please sign in to comment.