Search Issue Tracker
Fixed in 5.3.0
Votes
14
Found in
4.6.0f2
Issue ID
648688
Regression
No
When copying text in a multiline Input Field and then pasting it, new lines are ignored
To reproduce this issue:
1. Open the attached project
2. Open 'test' scene
3. It has input field with line type: 'Multi Line Newline'
4. Play the scene
5. Enter some text into multiple lines
6. Highlight text
7. Copy it(Control/CMD + C)
8. Paste it again
9. New lines are ignored and text is pasted into one line
Captured repro: http://screencast.com/t/QllgkKyxcCao
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Average FPS in Play Mode degradation on a newly created BiRP project when it's upgraded from 2020.3.48f1 to a newer Editor version
- DecoratorDrawer indentation is incorrect when it is called with EditorGUI
- Error "InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings." is present when using UI Toolkit and New Input System
- "Unable to get the list of approved APIs." is thrown when testing the App Packages with Windows App Certification Kit
- [Linux] The mouse wheel input is inverted when scrolling in the Build
JayDeveloper
Aug 26, 2015 03:22
A dirty solution to make newline pastable again:
// Use InputFieldM instead of InputField
public class InputFieldM : InputField
{
protected override void Append (string input)
{
if (HoldKeyManager.HoldCommandOnly && Input.GetKeyDown (KeyCode.V)) {
TextEditor te = new TextEditor ();
te.multiline = multiLine;
te.Paste ();
input = te.content.text;
}
if (TouchScreenKeyboard.isSupported)
return;
for (int i = 0, imax = input.Length; i < imax; ++i) {
char c = input [i];
Append (c);
}
}
}
JayDeveloper
Aug 26, 2015 02:55
If Unity team couldn't/wouldn't have time to get the InputField right, just make every function and member of the InputField object overridable(declaring functions virtual and members protected or public instead of private) so people who needs customized behaviour can write their own functionality by inheriting InputField.
Also, please liberate the use of GUIUtility.copySystemBuffer to developers. A better cross-platform copy and paste solution would be much better.
General advice: UI components are usually very customized. Instead of taking a closed approach of assuming many feature or behavior for developers, try opening up more API and settings of components. E.g. copy/paste keypress can be an event that allow developer to customize response; replace '\n' with space? why space?
Details on why newlines are replaced with space lies in code below:
// ----- InputField.cs ------
static string clipboard
{
get
{
TextEditor te = new TextEditor();
te.Paste();
return te.content.text;
}
set
{
TextEditor te = new TextEditor();
te.content = new GUIContent(value);
te.OnFocus();
te.Copy();
}
}
// ----- public class TextEditor ------
public bool Paste ()
{
string text = GUIUtility.systemCopyBuffer;
if (text != string.Empty)
{
if (!this.multiline)
{
text = TextEditor.ReplaceNewlinesWithSpaces (text);
}
this.ReplaceSelection (text);
return true;
}
return false;
}
// ----- End of code reference -----
*I suspect InputField.cs is written by an intern.
riwalk
Aug 22, 2015 21:32
This is really quite easy to reproduce and is extremely annoying. What good is a text field if it doesn't work?
JayDeveloper
Aug 22, 2015 03:43
Sorry, it's my own problem that '/' is ignored. '/' should be fine.
JayDeveloper
Aug 22, 2015 03:28
'/' is also ignored
GroenBoer
Aug 05, 2015 23:43
Copy & pasting text from outside of Unity (such as notepad or a website) into an inputfield at runtime then any newline characters are removed by unity!
Anjin_nz
Jul 13, 2015 23:52
Something similar seems to be happening in Unity 5.1.0f3
Anjin_nz
Jul 13, 2015 23:49
Something similar seems to be happening in Unity 5.1.0f3
Morgan
May 20, 2015 03:24
Tabs are also ignored