multi-line textGadget & single line text input ?

Just starting out? Need help? Post your questions and find answers here.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

multi-line textGadget & single line text input ?

Post by vmars316 »

Hello & Thanks ,
Two things I need to do:
1) How to make multi-line textGadget ?
I suspect it invloves CRLF but I don't know how code it .

2) What gadget to use to input a single line of text ?
I am used to a 'single line Edit' gadget , for things like
Name , Address , etc. .
It seems a waste to use a multiLine editor for one line of input .
What can I use ?
Thanks..vm
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
User avatar
mk-soft
Always Here
Always Here
Posts: 6215
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: multi-line textGadget & single line text input ?

Post by mk-soft »

1. Create EditorGadget with #PB_Editor_ReadOnyl
2. It´s Stringgadget

Code: Select all

Enumeration FormWindow
  #Window_0
EndEnumeration

Enumeration FormGadget
  #Editor_0
  #String_0
EndEnumeration


Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
  OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu)
  EditorGadget(#Editor_0, 10, 10, 580, 80, #PB_Editor_ReadOnly)
  SetGadgetColor(#Editor_0, #PB_Gadget_BackColor,RGB(0,252,255))
  StringGadget(#String_0, 10, 100, 580, 30, "")
EndProcedure

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: multi-line textGadget & single line text input ?

Post by TI-994A »

vmars316 wrote:1) How to make multi-line textGadget ?
2) What gadget to use to input a single line of text ?
I am used to a 'single line Edit' gadget...
It seems a waste to use a multiLine editor for one line of input .
Hi vm. You're right about the #CRLF$ in text gadgets. And for inputting a single line of text, you could use a StringGadget(), as mk-soft had pointed out:

Code: Select all

Enumeration
  #MainWindow
  #text1
  #text2
  #string1
EndEnumeration

LoadFont(0, "Arial", 14)
SetGadgetFont(#PB_Default, FontID(0))
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered 
OpenWindow(#MainWindow, 10, 10, 430, 280, "PureBasic String Gadgets", wFlags)

TextGadget(#text1, 10, 10, 200, 200, "Text gadgets are multi-line by default. " + 
                                     "They will wrap the text automatically " + 
                                     "to fit their widths - but not heights...")

tgStr$ = "But, you can use" + #CRLF$ + "the #CRLF$" + #CRLF$ + "to break" + #CRLF$ + 
         "the lines" + #CRLF$ +  "wherever" + #CRLF$ + "you" + #CRLF$ + "wish..."
TextGadget(#text2, 220, 10, 200, 200, tgStr$)

StringGadget(#string1, 10, 220, 410, 50, "This is a single-line input gadget...")

SetGadgetColor(#text1, #PB_Gadget_BackColor, RGB(0, 252, 255))
SetGadgetColor(#text2, #PB_Gadget_BackColor, RGB(255, 0, 255))

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
:D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
mk-soft
Always Here
Always Here
Posts: 6215
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: multi-line textGadget & single line text input ?

Post by mk-soft »

I did not even realize that the text gadget wordwrap and multiline can.
From which version it was changed because.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: multi-line textGadget & single line text input ?

Post by vmars316 »

Thanks Folks .
Exactly what I needed !
..vm
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Post Reply