TextMeshPro Input field - can't set placeholders' wrapping to enabled? - unity3d

I am trying to have a TMP Input Field with multiline (wrapped) placeholder. The input field has its content type set to Integer Number. Placeholder text has some string as text and has wrapping set to "enabled". In prefab editor, it looks ok (text is wrapped). However, when the scene loads, placeholder text immediately has its wrapping reset to "disabled".
The problem: I assume Input field resets the wrapping to disabled on child text, because its content is not multiline, as specified here. I can't set the input field to accept multiline - the option is not in inspector; I can see it if I switch to Debug mode, but as soon as I set it to multiline it switches back to single line. So, how do I set the wrapping on placeholder to enabled without it getting switched back to disabled in runtime? Or, alternatively, how do I set my InputFiled to be multiline (I assume that will fix the wrapping on the placeholder)?
What I have for now:
I have an input field that works like this: when it's not focused, there is a multiline text, for example: "Write your\nnumber here!". When focused, it's replaced by empty line and user can enter an integer number. On finishing input (OnEndEdit) I use the input to spawn some GameObjects and then replace the text again with "Write your\nnumber here!". Editor screenshot:
Right now it works as I expect. However, now I want to dynamically change the placeholder text, so I don't know where the newline will be and I would like for TMP to wrap the text for me, same as it does in Text component with Wrapping enabled.
So: how do I use TMP's wrapping - enabled on InputField without it getting reset to disabled? Either both the user input and placeholder, or just on placeholder itself - doesn't matter.

MultiLine is only available if the Content Type is set to Standard or Auto Corrected.
As soon as you set the input type to Integer Number it basically behaves just like an integer field in the Unity Inspector: No line wrapping but rather overfloating and scrolling to the right.
Alternatively if you need multi lines you could set the Content Type to Custom and then fully flexible adjust it to your needs like e.g.
LineType : Multi Line Newline
Line Limit: 0
Input Type: Standard
Keyboard Type: Default
Character Validation: Integer
And in general: Of course you also can't set a text to an input field that only accepts integer numbers ;) Rather set your placeholder text in the Placeholder object!
Anything that is applied to the Placeholder will be displayed automatically as long as there is no value typed in the input field!

Related

JavaFX: Need a custom control based on TextArea

I have the following requirement (sorry, but I'm quite new to JavaFX).
I need to have a custom TextArea that supports not only entering text but also entering a kind of macro.
This Macro has a unique ID and an associated text. The text should be displayed in the TextArea but with an e.g. light grey background. This is because it should behave as a unit.
You should not be able to click inside the macro and add a char there. The cursor should be placed behind the macro. And is you press just backspace the complete macro should be deleted.
If you call something like getRawContent() of the custom TextArea you should get a placeholder for the macro and not the associated text like:
getRawContent()
==> "This is text part one MACRO:132 This is text part two"
If the macro 132 has the following text associated "XXX123XXX", you will see inside the custom TextArea:
This is text part oneXXX123XXXThis is text part two"
But the text XXX123XXX has a light grey background to show that this text is associated with a macro and could be deleted, copied, and so on as a whole unit. Could be italic as well as in the above line. Should be only a bit different to the generic text.
Could someone assist me?
My Custom Control works now. I used an Eventfilter to prevent the internal Eventhandler to process the keypressed events in order to set the caret position behind a macro or delete the complete macro when DEL or BACKSPACE is pressed, this works.
And I use a Mouselistener to prevent that someone clicks and set caret position inside a macro.
So now I have only the problem left to mark the text somehow that the user can see what is normal text and what macro content.
Maybe I close here and open a new question.

How to have text of 2 different colors with Material-UI text field?

I'm trying to add an autocomplete feature in my project and I'd like the possible autocomplete data to be a greyed out, unselectable and without affecting the user typing.
If I could get the placeholder to be always visible that could work.
I tried setting the value prop of TextField to an JSX.Element but it only accepts primitive types. Fortunately I am using monospace fonts.
What are my options?
A div that is always visible and on-top?
2 text field next to each other with no padding or margin?
Somehow make the placeholder always visible?
Forced example (ignore the cursor)

How to set position label text in TextFormField in outlineborder?

How to set position label in TextFormField in outlineborder?
i want set text position. Because, label prefer to bottom not center in border
According to the documentation for the label
Text that describes the input field.
When the input field is empty and unfocused, the label is displayed on
top of the input field (i.e., at the same location on the screen where
text may be entered in the input field). When the input field receives
focus (or if the field is non-empty), the label moves above (i.e.,
vertically adjacent to) the input field.
So, basically this is the behavior for the label. If you want something else you have to make it on your own ( using a Stack widget with a TextField and a Text ). But with this solution you have to treat the focus properties as well on your own.
You can use this post as a reference
https://stackoverflow.com/a/58039585/10143503

Hide certain characters in a text field in Flutter

I have a text field which I need to style for example with bold or italics parts.
I tried overridding the TextEditingController's buildTextSpan and formatting the text using annotation ranges with custom styles but the edge cases were too much and I really couldn't get it to work.
So, thought about using a formatter where before every change in format I'll add a custom character, like this:
This text is |bBOLD and this is |iITALICS. Would get me this:
This text is BOLD and this is ITALICS. So I override the buildTextSpan to build the TextSpan from a parse function where I split the text by the special characters and check the initial letter of each text for formatting info.
This works well except for the fact that when I press the right arrow to go the next character after the "This text is ", the cursor will stay fixed as it thinks there are two characters but being only for formatting, they aren't there on the render.
Is there any way I could tell the textfield to ignore certain characters when selecting, moving selection or typing?
I think this would work!
static const kCharToBEIgnored = 0x2C;
// Here 0x2C means ',' comma
// For complete list visit https://api.flutter.dev/flutter/charcode/charcode-library.html
String get text {
return String.fromCharCodes(
_value.text.codeUnits.where((ch) => ch != kCharToBEIgnored),
);
}

LibreOffice Calc - text in a cell ending with an underscore and by a number will be converted to a small number

In LibreOffice Calc, If you enter text in a Standard cell ending with an underscore followed by a number, then the text is converted in the following way: the underscore is removed and the number is set in a small font (subscript).
Exemple:
If I enter TEST_1 in a cell and press Enter, then the content of the cell is replaced by TEST₁
How is it possible to cancel this behavior ?
The autocorrect behavior depends on the language.
In my case the Autocorrect options (in menu Tools->Autocorrect) were set to French (France).
The autocorrect rules causing this problem were in the form
.*_0 converted to ₀
It is possible to delete these rules to avoid the problem.