textField cueText and setfocus

  1. 3 months ago

    Hello,
    on a Mac, when a textfield is blank, the cueText becomes visible, and if I set textField1.setfocus, that object gets the focus retaining the cueText visible.

    On Windows (X), I see that the cueText becomes visible only if a blank textField does not have the focus.

    And setting textField1.setfocus, not only the cueText becomes invisible, but the textField itself freezes for a few seconds, that is: the beam stops blinking for a few seconds (and from another project it seems that code following "textField1.setfocus" stops its execution till I click in the textField).

    BTW. I noticed this behavior years ago. But since I'm not a Windows man, I'd like to know if all this is the expected behavior.
    If not, is there a way to have the cueText appear when the textField is blank? And to avoid what I called the "freezing" at setfocus?

    New project created and built on Mac (Mojave); built.exe tested on a Windows X PC.
    Thanks.

  2. Alberto D

    Jul 18 Pre-Release Testers

    https://docs.xojo.com/TextField.CueText

    Notes
    On Windows and Linux, the Cue Text only appears when the TextField does not have focus.

  3. Julian S

    Jul 18 Pre-Release Testers, Xojo Pro UK
    Edited 3 months ago

    I don't know why this isn't a feature, I guess cross platform consistency. Put this in your TextField.GotFocus

    Declare Function SendMessage Lib "User32.dll" Alias "SendMessageW" (hWnd As Integer, Msg As UInt32, wParam As UInteger, lParam As WString) As Integer
    Const EM_SETCUEBANNER = &h1501
    Call SendMessage(Me.Handle, EM_SETCUEBANNER, 1, Me.CueText)

    Its not perfect as the xojo one sometimes overrides it and makes it vanish, e.g. if you click into the field while the field has focus. I could probably get really technical and intercept the xojo's call to EM_SETCUEBANNER to stop that happening but its a time vs feature vs sanity thing ;)

  4. Andre K

    Jul 19 Pre-Release Testers

    What i see now in the latest alpha is that the cuetext does not show up on windows at all, only after applying Julian's system call it's working.

  5. @Alberto D

    Notes
    On Windows and Linux, the Cue Text only appears when the TextField does not have focus.

    My bad. Before sending the original post I had checked LR and missed the Note. Getting too old?

    I'll keep in mind Julian's system call and Andre's observation about cuetext lately not showing up.

    About setting textField.setfocus: I confirm that after a few of seconds the i-beam stops blinking for five or six seconds, but it does NOT freeze code-execution. In fact, during the pseudo-freezing seconds, I can safely write into the textField. So I can happily live with it.

    Thank you for answering.

  6. Greg O

    Jul 19 Xojo Inc

    @Andre K What i see now in the latest alpha is that the cuetext does not show up on windows at all, only after applying Julian's system call it's working.

    Could you file a bug report about that?

  7. Andre K

    Jul 19 Pre-Release Testers

    Done:
    Feedback Case #56417

  8. Alberto D

    Jul 19 Pre-Release Testers

    @Andre K Done:
    Feedback Case #56417

    If you only have 1 TextField then it will always have the Focus, and as the docs say:

    Notes
    On Windows and Linux, the Cue Text only appears when the TextField does not have focus.

    I didn't test this, but if you add a second TextField to your test code and set CueText there, the TextField without focus will show the CueText even without the declare.

  9. Andre K

    Jul 19 Pre-Release Testers
    Edited 3 months ago

    @Alberto D , you are right, just tried it and it appears indeed the having focus that caused it.

    Thanks for bringing this up.
    The info added to the feedbackreport.

or Sign Up to reply!