[SOLVED] simple multiline with max length text?
- doctorized
- Addict
- Posts: 856
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
[SOLVED] simple multiline with max length text?
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.
Re: simple multiline with max length text?
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
- doctorized
- Addict
- Posts: 856
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: simple multiline with max length text?
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.firace wrote: ↑Thu Sep 16, 2021 9:16 pmCode: 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
Re: simple multiline with max length text?
This works as expected: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.
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
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.
- doctorized
- Addict
- Posts: 856
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: simple multiline with max length text?
I wrote that I want to have multiline support meaning word wrap.infratec wrote: ↑Fri Sep 17, 2021 12:43 pmThis works as expected: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.You did not write that you want wordwrap.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
Do you want this, then you have to note this.
Re: simple multiline with max length text?
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
Re: simple multiline with max length text?
Hi firace
A little add on to be exact 80 char
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
Re: simple multiline with max length text?
Multi-line doesn't mean word-wrap; they're two totally different things. You can have multi-line without word-wrap. Examples:doctorized wrote: ↑Fri Sep 17, 2021 12:56 pmI wrote that I want to have multiline support meaning word wrap.
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
- doctorized
- Addict
- Posts: 856
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: simple multiline with max length text?
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!
RASHAD, I will check your addition. Thank you!
Re: simple multiline with max length text?
You don't need to apologize - I just wanted to make sure you knew the difference.