Is it possible to have a Multiline TextField?

  1. 3 months ago

    Ivan T

    Jul 18 Pre-Release Testers

    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 Feedback Case #56415, but in the meantime, Is there a way to have a multiline TextField control? Maybe declares or another hack

    Thanks

  2. Markus W

    Jul 18 Pre-Release Testers #JeSuisHuman New Zealand, Auc...
    Edited 3 months ago

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

    Ah - do you mean the Focus ring?

    Turn off Focus for the TextField?

  3. Ivan T

    Jul 18 Pre-Release Testers

    @Markus W Turning off styled for the TextArea in the IDE not helping?

    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:

    -image-

  4. Markus W

    Jul 18 Pre-Release Testers #JeSuisHuman New Zealand, Auc...
    Edited 3 months ago

    Turn off UseFocusRing for the TextField?

    Turn Border off

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

  5. Emile S

    Jul 18 Europe (France, Strasbourg)
    Edited 3 months ago

    Edit: in the Open Event.

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

    Works like a charm !

    What was the question ? ;)

  6. Wayne G

    Jul 18 Pre-Release Testers, Xojo Pro New Zealand axisdirect.nz
    Edited 3 months ago

    What @Markus W said

    -image-

  7. Ivan T

    Jul 18 Pre-Release Testers

    @Wayne G
    -image-

    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

  8. Emile S

    Jul 18 Europe (France, Strasbourg)

    @Emile S in the Open Event.

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

    Works like a charm !

    ?

  9. Ivan T

    Jul 18 Pre-Release Testers

    @Emile S Line #1." + EndOfLine + EndOfLine +_
    "Line #3 !"

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

  10. Alberto D

    Jul 18 Pre-Release Testers

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

  11. Ivan T

    Jul 18 Pre-Release Testers

    @Alberto D 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

  12. Michel B

    Jul 19 Pre-Release Testers, Xojo Pro RubberViews.com

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

  13. Emile S

    Jul 19 Europe (France, Strasbourg)
    Edited 3 months ago

    @Ivan T Just show a single line with "Line #1. Line #3 !"

    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) :(
    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…)

  14. Michel B

    Jul 19 Pre-Release Testers, Xojo Pro RubberViews.com

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

    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 T : Drag a textfield to the window, the click on "Super" in the Inspector, and select "TextArea". You will find the multiline property.

  15. Alberto D

    Jul 19 Pre-Release Testers

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

  16. Ivan T

    Jul 19 Pre-Release Testers

    @Michel B 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 T : Drag a textfield to the window, the click on "Super" in the Inspector, and select "TextArea". You will find the multiline property.

    As @Alberto D said, that is the same as dragging a TextArea directly, that why I wrote in the first post:

    @Ivan T I know, "use a Textarea", but...

    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.

  17. Ivan T

    Jul 23 Pre-Release Testers
    Edited 3 months ago

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

    -image-

    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

or Sign Up to reply!