Is it possible to assign FLAG on a case-by-case basis?

Posted By: gamers

Is it possible to assign FLAG on a case-by-case basis? - 12/28/21 15:36

Hello guys,

I ran into a problem and no matter what I did, I couldn't find a solution. I'm trying to develop a content where the user is asked a question and after a while I want them to remember the information given for that question.
If the user writes a response longer than 50 characters real-time while entering the response in the response field, I want to make the response go one line.
I was able to do this with the WWRAP flag feature, but even if the user types a character, the cursor immediately goes to the bottom line. I want to prevent this.
As soon as the user reaches 50 characters while typing the reply, I want to make sure that the cursor goes down to one line and writes the reply.

In other words, as soon as the user reaches 50 characters, I want to enable WWRAP in the code I shared below. How can I do that?

Code
TEXT* retention_name_txt = 
{
       pos_x = 70;
       pos_y = 180;
       layer = 11;
       red=0;
       green=0;
       blue=0;
       font = "Calibri#30";
       string(retention_name_str);
       flags = FILTER /*| WWRAP*/;
       size_x=1800;
}
Posted By: 3run

Re: Is it possible to assign FLAG on a case-by-case basis? - 12/28/21 16:27

Originally Posted by manual
a flag is set by or-ing the flags parameter with the flag (text.flags |= SHOW;) and reset by and-ing the flags parameter with the inverse flag (text.flags &= ~SHOW;).
So you could do:
Code
retention_name_txt.flags &= ~WWRAP; // to reset
retention_name_txt.flags |= WWRAP; // to set
Also, you could check for the length on the string with str_len.

But I would personally use imgui for this purposes, cause it's very simple and easy to use + offers much more than acknex panels/texts has.
You can find it here:
Imgui Lite-C Development

Best regards.
Posted By: gamers

Re: Is it possible to assign FLAG on a case-by-case basis? - 12/29/21 07:57

Originally Posted by 3run
Originally Posted by manual
a flag is set by or-ing the flags parameter with the flag (text.flags |= SHOW;) and reset by and-ing the flags parameter with the inverse flag (text.flags &= ~SHOW;).
So you could do:
Code
retention_name_txt.flags &= ~WWRAP; // to reset
retention_name_txt.flags |= WWRAP; // to set
Also, you could check for the length on the string with str_len.

But I would personally use imgui for this purposes, cause it's very simple and easy to use + offers much more than acknex panels/texts has.
You can find it here:
Imgui Lite-C Development

Best regards.


Hi 3run,

Thank you for replying. I'll try the flag method you said. But IMGUI looks really nice. What I want is to create a text box that supports multi-line typing and let the user type in this field. On the other hand, I don't know how to integrate IMGUI's textbox feature into my own project.
Posted By: 3run

Re: Is it possible to assign FLAG on a case-by-case basis? - 12/29/21 14:58

It's actually quite easy to use, just download the demo and study the code, it's not as hard as you might have imagined it. Multi-line is created withing few lines of code!
Posted By: gamers

Re: Is it possible to assign FLAG on a case-by-case basis? - 12/29/21 16:02

Originally Posted by 3run
It's actually quite easy to use, just download the demo and study the code, it's not as hard as you might have imagined it. Multi-line is created withing few lines of code!


Thanks for your response 3run.
How can I write the code to enable WWRAP flag when the number of characters entered exceeds 50 as the user continues to enter characters in the text box?
Posted By: gamers

Re: Is it possible to assign FLAG on a case-by-case basis? - 12/29/21 16:11

Actually, what I want to do is exactly; real-time consideration of the number of characters entered as the user enters a response, and activation of the WWRAP function when the number of characters exceeds 50. I could never do this.
© 2024 lite-C Forums