Page 1 of 1

"Word wrap" in multi-line StringGadgets?

Posted: Wed Jun 11, 2003 11:58 pm
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

Posted: Thu Jun 12, 2003 12:06 am
by Jones1969
Sorry, I have to use the EditorGadget of course.

Here's the code from El_Choni.

/Jones

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

Posted: Thu Jun 12, 2003 5:25 am
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

Aww shucks.

Posted: Thu Jun 12, 2003 6:44 am
by Fangbeast
Can't take credit for this, found this on the forum last year (the old forum) :):)

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

Posted: Wed Oct 29, 2003 9:42 pm
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?

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

Posted: Wed Oct 29, 2003 9:55 pm
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. :)