Page 1 of 1

multi-line textGadget & single line text input ?

Posted: Thu Apr 16, 2015 11:09 pm
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

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

Posted: Thu Apr 16, 2015 11:33 pm
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


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

Posted: Fri Apr 17, 2015 6:07 am
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

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

Posted: Fri Apr 17, 2015 10:01 am
by mk-soft
I did not even realize that the text gadget wordwrap and multiline can.
From which version it was changed because.

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

Posted: Fri Apr 17, 2015 3:26 pm
by vmars316
Thanks Folks .
Exactly what I needed !
..vm