Wrapping TextField

Basically I have a document window and a properties window. In the properties window, I have a TextArea, so that the user can enter multiple lines of text. It works well unless I have the Apple color picker open, in which case, when the window is activated the color picker turns to the color of the text within the TextArea (Styled set to off), which in turn then updates the current color in my document window.

Rather frustratingly, the color is changed before any Xojo events are fired such as the window activate or the TextArea gotFocus. Making it difficult for me to break the connection to the main window.

After spending most of last night reading Apple’s Docs, I now understand why this is. So I started looking into work arounds. In Xcode there is a Wrapping NSTextField, which is like a regular TextField with lineBreaking set to WordWrapping. However while I can set this value of the underlying NSTextFieldCell, it makes no difference to the TextField within Xojo.

To Reproduce:
Create a new project, add a TextField to it and make it’s height quite tall. Set some default text so that it spills off the end. Then in the open event of the Window add the following code.

[quote] declare function wraps lib “Cocoa” selector “wraps” ( ref as integer ) as boolean
declare sub setWraps lib “Cocoa” selector “setWraps:” ( ref as integer, inValue as boolean )
declare sub setUsesSingleLineMode lib “Cocoa” selector “setUsesSingleLineMode:” ( ref as integer, inValue as boolean )
declare function getCell lib “Cocoa” selector “cell” ( ref as integer ) as integer
declare sub setScrollable lib “Cocoa” selector “setScrollable:” ( ref as integer, inValue as boolean )
declare sub setLineBreakMode lib “Cocoa” selector “setLineBreakMode:” ( ref as integer, inMode as integer )

Dim NSTextCell as integer = getCell( TextField1.handle )
setLineBreakMode( NSTextCell, 0 )
setUsesSingleLineMode( NSTextCell, false )
setScrollable( NSTextCell, True )

Dim v as variant = wraps( NSTextCell )
MsgBox "Wrapping: " + v.stringValue[/quote]

Run the application. You should get a MsgBox saying “Wrapping: True”, however the Text never wraps. If anyone can tell me what I’m missing, I would be very grateful.

After firing up Xcode, I was able to write some Obj-C code that gives me the functionality I’m looking for, I then translated it into Xojo and while it works, it reverts back to a single line when the field has focus.

I’ve logged a Feedback report (if anyone else is interested).