[SOLVED] simple multiline with max length text?

Just starting out? Need help? Post your questions and find answers here.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

[SOLVED] simple multiline with max length text?

Post by doctorized »

I want to have a box and the user write text in it. I want to have miltiline support so the user will be able to see all of the typed text. The text will be limited to a specific amount of chars. On one hand there is StringGadget with #PB_String_MaximumLength. On the other hand there is EditorGadget with #PB_Editor_WordWrap. I found a code from 2003 referring #PB_String_Multiline but it is not present any more. So, how can I do?
Last edited by doctorized on Fri Sep 17, 2021 1:24 pm, edited 1 time in total.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: simple multiline with max length text?

Post by firace »

Code: Select all



OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)

t$="Multiline StringGadget. Max 80 ch."+Chr(13)+Chr(10)
For r=1 To 3 : t$+"Line " + Str(r)+Chr(13)+Chr(10) : Next
StringGadget(0,10,10,200,100,t$,#ES_MULTILINE)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: simple multiline with max length text?

Post by doctorized »

firace wrote: Thu Sep 16, 2021 9:16 pm

Code: Select all



OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)

t$="Multiline StringGadget. Max 80 ch."+Chr(13)+Chr(10)
For r=1 To 3 : t$+"Line " + Str(r)+Chr(13)+Chr(10) : Next
StringGadget(0,10,10,200,100,t$,#ES_MULTILINE)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

This code is not suitable as the text will no be writen by my app but the user will write it. Try to write text to your code. All text appears in one line.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: simple multiline with max length text?

Post by infratec »

I want to have a box and the user write text in it. I want to have miltiline support so the user will be able to see all of the typed text. The text will be limited to a specific amount of chars.
This works as expected:

Code: Select all

OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)

StringGadget(0,10,10,200,100,"",#ES_MULTILINE)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
You did not write that you want wordwrap.
If you want this, then you have to note this.
Last edited by infratec on Fri Sep 17, 2021 1:23 pm, edited 1 time in total.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: simple multiline with max length text?

Post by doctorized »

infratec wrote: Fri Sep 17, 2021 12:43 pm
I want to have a box and the user write text in it. I want to have miltiline support so the user will be able to see all of the typed text. The text will be limited to a specific amount of chars.
This works as expected:

Code: Select all

OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)

StringGadget(0,10,10,200,100,"",#ES_MULTILINE)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
You did not write that you want wordwrap.
Do you want this, then you have to note this.
I wrote that I want to have multiline support meaning word wrap.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: simple multiline with max length text?

Post by firace »

New test:

Code: Select all



OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)

t$="Multiline StringGadget. Max 80 ch."+Chr(13)+Chr(10)
For r=1 To 3 : t$+"Line " + Str(r)+Chr(13)+Chr(10) : Next
StringGadget(0,10,10,200,100,t$,#ES_MULTILINE | #ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4635
Joined: Sun Apr 12, 2009 6:27 am

Re: simple multiline with max length text?

Post by RASHAD »

Hi firace
A little add on to be exact 80 char

Code: Select all


OpenWindow(0,0,0,300,300,"test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

t$="Multiline StringGadget. Max 80 ch."+#CRLF$
For r=1 To 50 : t$+"Line " + Str(r)+#CRLF$: Next
t$ = Left(t$,80)
StringGadget(0,10,10,280,280,t$,#ES_MULTILINE|#ESB_DISABLE_BOTH)
SetGadgetAttribute(0, #PB_String_MaximumLength, 80)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: simple multiline with max length text?

Post by BarryG »

doctorized wrote: Fri Sep 17, 2021 12:56 pmI wrote that I want to have multiline support meaning word wrap.
Multi-line doesn't mean word-wrap; they're two totally different things. You can have multi-line without word-wrap. Examples:

Code: Select all

This is single line

Code: Select all

This is multil
ine without wo
rd wrap

Code: Select all

This is
multiline with
word wrap
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: simple multiline with max length text?

Post by doctorized »

I thought multiline is word wrap. My bad. I apologize. firace's code is what I need. Thank you all for your replays!
RASHAD, I will check your addition. Thank you!
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: simple multiline with max length text?

Post by BarryG »

You don't need to apologize - I just wanted to make sure you knew the difference.
Post Reply