EditorGadget and Wordwrap and stuff

Just starting out? Need help? Post your questions and find answers here.
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

EditorGadget and Wordwrap and stuff

Post by SniffTheGlove »

Hi,

I am looking to add an editorgadget to a window to act as a location for notes, however I can not seem to get the text to correct along with the wordwrap. Is there a special way to solve this?
The attached code is taken from the EditorGadget help file with the addition of some long sentences and also the wordwrap flag on the gadget.

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    EditorGadget(0, 8, 8, 306, 133, #PB_Editor_WordWrap)
    For a = 0 To 5
      AddGadgetItem(0, a, "If You Take a Mouse to School by Laura Numeroff and Felicia Bond "+Str(a) +#CRLF$)
    Next
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
This is what I see when running the above code.
If You Take a Mouse to School by Laura Numeroff and Felicia If You Take a Mouse to School by Laura Numeroff and Felicia If You Take a Mouse to School by Laura If You Take a Mouse to School by Laura Numeroff and Felicia If You Take a Mouse to School by Laura Numeroff and If You Take a Mouse to School by Laura Numeroff and Felicia Bond 5

Felicia Bond 4

Bond 3

Numeroff and Felicia Bond 2

Bond 1

Bond 0
This is what I was expecting to see!!
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 0
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 1
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 2
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 3
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 4
If You Take a Mouse to School by Laura Numeroff and Felicia Bond 5
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: EditorGadget and Wordwrap and stuff

Post by infratec »

Remove the CRLF at the end of the line and use -1 instead of a as index.
Because with a linewrap the number of the item is messed up.

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    EditorGadget(0, 8, 8, 306, 133, #PB_Editor_WordWrap)
    For a = 0 To 5
      AddGadgetItem(0, -1, "If You Take a Mouse to School by Laura Numeroff and Felicia Bond "+Str(a))
    Next
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Bernd
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Re: EditorGadget and Wordwrap and stuff

Post by SniffTheGlove »

Thank you so much
Post Reply