Is it possible to have a Multiline TextField?

I know, “use a Textarea”, but…

Textarea uses the RichEdit Class, and even if is great for styled text, it has a different theme than the textfields (Edit Class) and the app looks bad with diferent borders on some of the fields.

I made a FR <https://xojo.com/issue/56415>, but in the meantime, Is there a way to have a multiline TextField control? Maybe declares or another hack

Thanks

Turning off styled for the TextArea in the IDE not helping?

Ah - do you mean the Focus ring?

Turn off Focus for the TextField?

Nop, it is funny, in the ide, when turning off the styled, changes the preview of the control, but in run time, it is the same RichEdit with the same look.

This is what I’m talking:

Turn off UseFocusRing for the TextField?

Turn Border off

Draw border yourself (eg put it onto a ContainerControl)?

Edit: in the Open Event.

Me.Text = "Line #1." + EndOfLine + EndOfLine +_ "Line #3 !"

Works like a charm !

What was the question ? :wink:

What @Markus Winter said

[quote=445888:@Wayne Golding]

[/quote]

Great idea, this will be my workaround for now. Instead of a rectangle, I used a canvas to draw the background acording to the state, and also the border to indicate the focus, as a last detail, make the TextArea smaller and 5px to the right. (The lack of padding also looks awfull).

Thanks

[quote=445887:@Emile Schwarz]in the Open Event.

Me.Text = “Line #1.” + EndOfLine + EndOfLine +_
“Line #3 !”

Works like a charm ![/quote]
?

[quote=445892:@Emile Schwarz]Line #1." + EndOfLine + EndOfLine +_
“Line #3 !”[/quote]

Just show a single line with “Line #1. Line #3 !”

My guess is that Emile tested on mac and not on Windows.

Wow, just tested on mac and, yes, the “Single line” TextField in xojo are not created with the “Single line mode” so, it is posible to edit multiline text.

Looks like the TextField also needs a Multiline property on MacOS

You may want to change the super of the TextField to TextArea.

Not here, I tested before sending the answer (else I would say nothing).

Michel: this does not work as expected: the set of properties does not change (stays the one for TextField) :frowning:
I try that too.

Edit: Sorry, because of my very small boot SSD size, I removed my Windows VM, so I do not tested on Windows (and I do not realized the question was for Windows, else…)

[quote=445913:@Emile Schwarz]Michel: this does not work as expected: the set of properties does not change (stays the one for TextField) :frowning:
I try that too.[/quote]

I just looked at it under Windows : changing super does change the set of properties. As expected. And it is fairly easy to come up with a multiline textfield that way.

@Ivan Tellez : Drag a textfield to the window, the click on “Super” in the Inspector, and select “TextArea”. You will find the multiline property.

Michel, what is the difference in doing that vs dragging a TextArea directly?

[quote=445970:@Michel Bujardet]I just looked at it under Windows : changing super does change the set of properties. As expected. And it is fairly easy to come up with a multiline textfield that way.

@Ivan Tellez : Drag a textfield to the window, the click on “Super” in the Inspector, and select “TextArea”. You will find the multiline property.[/quote]
As @Alberto DePoo said, that is the same as dragging a TextArea directly, that why I wrote in the first post:

[quote=445883:@Ivan Tellez]I know, “use a Textarea”, but…
[/quote]

Native EDIT control in windows (created with xojo TextField) can be Single line and multiline, but xojo only exposes the Single line option.

Changing the “Super” to “TextArea” or dragging a “TextArea” directly, creates a Native RichEdit control in windows, this also can be single line or multine and Xojo exposes both behaviors. BUT it looks like very different than the TextField, breaking the UI of the app.

It really changes the look and feel of and app having properly themed controls.

Imagine if the IDE also have good looking multiline Textfields and Properly themed TextAreas…

Until xojo fixes this, if womeone is interested on having a better look in your app:

  • Fixing the padding:

#If TargetWindows Then
  
  Declare Sub GetClientRect Lib "User32" (handle As Integer, r As Ptr)
  Declare Sub InflateRect Lib "User32" (r As Ptr, dx As Int32, dy As Int32)
  Declare Function SendMessageA Lib "User32" (hWnd As Integer, Msg As Integer, wParam As Integer, lParam As Ptr) As Integer
  Declare Function SendMessageW Lib "User32" (hWnd As Integer, Msg As Integer, wParam As Integer, lParam As Ptr) As Integer
  
  Dim mb As New MemoryBlock (16)
  GetClientRect (Me.Handle, mb)
  InflateRect (mb, -6, -3)
  
  Const EM_SETRECT = &h00B3
  
  If System.IsFunctionAvailable ("SendMessageW", "User32") Then
    Call SendMessageW (Me.Handle, EM_SETRECT, 0, mb)
  Else
    Call SendMessageA (Me.Handle, EM_SETRECT, 0, mb)
  End If
  
  Me.Refresh
  
#EndIf

-Disable the controls border.

As for the border, since it will requiere to intercept the Paint message and custom draw using the theme framewor of the OS, I just put the TextArea over a canvas that draws a rect whith color Realbasic.FrameColor or Realbasic.HiglightColor

Hello Ivan,

Can you post an example code of your fix, caus don’t work for me.

Thanks a lot