textField cueText and setfocus

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.


On Windows and Linux, the Cue Text only appears when the TextField does not have focus.[/quote]

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 :wink:

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.

@Alberto DePoo [quote]Notes
On Windows and Linux, the Cue Text only appears when the TextField does not have focus.[/quote]
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.

Could you file a bug report about that?


[quote=445958:@Andre Kuiper]Done:
If you only have 1 TextField then it will always have the Focus, and as the docs say:

On Windows and Linux, the Cue Text only appears when the TextField does not have focus.[/quote]

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.

@Alberto DePoo , 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.