"Word wrap" in multi-line StringGadgets?

Just starting out? Need help? Post your questions and find answers here.
Jones1969
New User
New User
Posts: 7
Joined: Fri May 02, 2003 9:35 am
Location: Denmark

"Word wrap" in multi-line StringGadgets?

Post by Jones1969 »

I can't seem to find a way to auto word wrap user input in a multi-line StringGadget.

I found this old thread and some others, but none of them give a solution that works.
It would seem a natural thing, as right-justified StingGadgets can be tricked into wrapping just fine!!

No user can be expected to enter text in a field that scrolls sideways!
Come on, please tell me this has been worked out for v. 3.70! Anyone?

/Jones
<FONT color="DarkGray" size="1">Registered PureBasic user. (Win 98 2nd, AMD Duron, 800 MHz, 192 MB RAM)</FONT>
Jones1969
New User
New User
Posts: 7
Joined: Fri May 02, 2003 9:35 am
Location: Denmark

Post by Jones1969 »

Sorry, I have to use the EditorGadget of course.

Here's the code from El_Choni.

/Jones
<FONT color="DarkGray" size="1">Registered PureBasic user. (Win 98 2nd, AMD Duron, 800 MHz, 192 MB RAM)</FONT>
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: "Word wrap" in multi-line StringGadgets?

Post by PB »

> I can't seem to find a way to auto word wrap user input in a
> multi-line StringGadget.

Here ya go (thanks to FangBeast for the disable flags):

Code: Select all

If OpenWindow(0,200,200,300,200,#PB_Window_SystemMenu,"test")
  CreateGadgetList(WindowID())
  t$="This text goes inside a multiline StringGadget."+Chr(13)+Chr(10)
  For r=1 To 10 : t$+Str(r)+Chr(13)+Chr(10) : Next
  StringGadget(0,10,10,200,100,t$,#PB_String_Multiline|#ES_AUTOVSCROLL|#WS_VSCROLL|#WS_HSCROLL|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT)
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Aww shucks.

Post by Fangbeast »

Can't take credit for this, found this on the forum last year (the old forum) :):)
Amateur Radio, D-STAR/VK3HAF
Banaticus
User
User
Posts: 21
Joined: Fri Oct 24, 2003 5:49 am
Location: Redlands, CA
Contact:

Re: "Word wrap" in multi-line StringGadgets?

Post by Banaticus »

PB wrote:#ES_AUTOVSCROLL #WS_VSCROLL #WS_HSCROLL #ESB_DISABLE_LEFT #ESB_DISABLE_RIGHT
Where do these come from? I tried searching in the help menu for them, but haven't been able to find them yet. Where can I find more information on them?

It seems that autovscroll sets it to automatically scroll vertically. I don't really see why hscroll is needed. Disable_left and disable_right must stop the code from scolling past the edge of the box to the left and the right.

But why do these codes turn the string box into a right-justified box? Perhaps it's hscroll that makes the box become right-justified?
--BX
Banaticus
User
User
Posts: 21
Joined: Fri Oct 24, 2003 5:49 am
Location: Redlands, CA
Contact:

Re: "Word wrap" in multi-line StringGadgets?

Post by Banaticus »

Why does this work? Comments inline

Code: Select all

If OpenWindow(0,200,200,300,200,#PB_Window_SystemMenu,"test")
  CreateGadgetList(WindowID())
  t$="This text goes inside a multiline StringGadget."+Chr(13)+Chr(10)
;a string variable was created -- t$ is equal to the text plus some control characters
;t$ is displayed when the StringGadget is created later on

  For r=1 To 10 : t$+Str(r)+Chr(13)+Chr(10) : Next
;text has been created -- but this information shouldn't be displayed
;see further comments after the code

  StringGadget(0,10,10,200,100,t$)
;we display t$ at this point when we create the stringgadget

  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
That text, t$+Str(r)+Chr(13)+Chr(10), shouldn't be displayed from what I can tell. It's not saved to a variable, so it has to be displayed right then. But, SetGadgetText() isn't used, Print() isn't used . . . from what I can tell, this text shouldn't be displaying. And yet, somehow, it displays. Why? What am I missing?

Thanks. :)
--BX
Post Reply