Setting wordwrap to auto in editor gadget
Posted: Wed Jul 25, 2007 8:18 pm
Here is my attempt to use Carbon API to set wordwrap to auto for an editorgadget.
It compiles without error but does not make the text wordwrap. What have I done wrong?
Code: Select all
;OSX Wordwrap Test
;Uses Carbon API calls
;imported to purebasic using pbsoimporter
;wordwrap.pbl
;
;-framework Carbon
;GetControlProperty 6
;TXNSetTXNObjectControls 5
;-Init Variables
displaytext.s=""
status.l=0
Dim controlTag.l(0)
Dim controlData.b(0)
hWnd=OpenWindow(0, 100, 100, 450, 300, "OSX Wordwrap Test", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)
If hWnd=0 Or CreateGadgetList(hWnd)=0:End:EndIf
EditorGadget(1, 10, 10, 430, 280, #PB_Editor_ReadOnly)
; this is the code that should set wordwrap to auto
If GetControlProperty_(GadgetID(1), 'PURE', 'TXOB', 4, 0, @TextObject.l) = 0 ;TextObject found
controlTag(0) = 'wwrs' ;kTXNWordWrapStateTag constant
controlData(0) = false ;kTXNAutoWrap constant
status = TXNSetTXNObjectControls_(TextObject, false, 1, controlTag, controlData)
EndIf
; populate editorgadget with some text to test for auto wordwrap
For i=1 To 20
displaytext=displaytext+" this is a wordwrap test :"
Next
SetGadgetText(1, displaytext)
;main loop
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End