cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shivakumarcm1
Frequent Visitor

Press enter in TextInput to move to next line in HTML text control

Hi All,

I'm trying a scenario where I type a message on the text input and hit enter button on keyboard, the text moves to the next line in the HTML text control.
Note: a line break functionality is in place where the line breaks and move to next line after 25 characters.

Shivakumarcm1_0-1669803307439.png

 


Could anyone give me some guidance on how to proceed further?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
BCBuizer
Super User
Super User

Hi @Shivakumarcm1 ,

 

Not the prettiest, but I think this does the job you need it to do:

 

BCBuizer_0-1670929098228.png

 

Clear(colValues);
Clear(colLines);
ForAll(
    Substitute(
        Split(
            TextInput1.Text,
            ""
        ),
        Char(10),
        "<br>"
    ) As _Characters,
    Collect(
        colValues,
        _Characters.Result
    );
    If(
        _Characters.Result = "<br>",
        Collect(
            colLines,
            Concat(
                colValues,
                Value
            )
        );
        RemoveIf(
            colValues,
            true
        )
    );
    If(
        CountRows(colValues) = 25,
        Collect(
            colValues,
            "<br>"
        );
        Collect(
            colLines,
            Concat(
                colValues,
                Value
            )
        );
        RemoveIf(
            colValues,
            true
        )
    )
);
Collect(
    colLines,
    Concat(
        colValues,
        Value
    )
);
UpdateContext(
    {
        _htmlinput: Concat(
            FirstN(
                colLines,
                5
            ),
            Value
        ) & If(
            CountRows(colLines) > 5,
            "..."
        )
    }
)

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

4 REPLIES 4
BCBuizer
Super User
Super User

HI @Shivakumarcm1 ,

 

Do you want the counter of 25 to be reset after the user inserted a line break or should it continue?

 

Example with reset:

1234567890123456789012345
1234567890
1234567890123451234567890
1234567890123451234567890

 

Example without reset:

1234567890123456789012345
1234567890
123456789012345
1234567890123456789012345
1234567890123456789012345

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
Shivakumarcm1
Frequent Visitor

Hi BCBuizer,
If i type the text in continuously, it has to break after 25 characters and move to the next line and start counting from 1 again.
if i click enter in the Textinput, the line breaks and move to the next line and starts counting from 1 again.
It has to be with reset as example 1 that you have shared above.

Is there any possibility to set maximum line limit to 5?
I tried couple of different codes suggested in google but didn't help.
code:
display: -webkit-box;
-webkit-line-clamp: 2; // <- you can change rows number
-webkit-box-orient: vertical;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;

BCBuizer
Super User
Super User

Hi @Shivakumarcm1 ,

 

Not the prettiest, but I think this does the job you need it to do:

 

BCBuizer_0-1670929098228.png

 

Clear(colValues);
Clear(colLines);
ForAll(
    Substitute(
        Split(
            TextInput1.Text,
            ""
        ),
        Char(10),
        "<br>"
    ) As _Characters,
    Collect(
        colValues,
        _Characters.Result
    );
    If(
        _Characters.Result = "<br>",
        Collect(
            colLines,
            Concat(
                colValues,
                Value
            )
        );
        RemoveIf(
            colValues,
            true
        )
    );
    If(
        CountRows(colValues) = 25,
        Collect(
            colValues,
            "<br>"
        );
        Collect(
            colLines,
            Concat(
                colValues,
                Value
            )
        );
        RemoveIf(
            colValues,
            true
        )
    )
);
Collect(
    colLines,
    Concat(
        colValues,
        Value
    )
);
UpdateContext(
    {
        _htmlinput: Concat(
            FirstN(
                colLines,
                5
            ),
            Value
        ) & If(
            CountRows(colLines) > 5,
            "..."
        )
    }
)

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
Shivakumarcm1
Frequent Visitor

This works as expected. Thank you @BCBuizer 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,643)