Clear Focus ?

Stupid !

I want to clear the focus in a window (some ComboBox, actually and one TextArea), but I do not found how to.

I must change my glasses.

Help !

I suppose one way to “clear” focus, is to give another control the focus with the OtherControl.SetFocus() method?

Yes Alvyn, but I only want to clear the focus; else I would use NextFocus or PreviousFocus (added in Real Studio 2009r3) or simply set the focus to a specific control.

I searched ClearFocus (from memory) but it disappears from my point of view…

Not sure what you searched for, but ClearFocus exists:
https://documentation.xojo.com/index.php/ClearFocus

ClearFocus is WIndows only… OP didn’t specify what platform, so this may or may not help

ClearFocus is both Mac and Win; the docs say:

Removes the focus from the control that has the focus, leaving no control with the focus. On Windows only, the application also no longer receives KeyDown events.

I’ve just tried it on a Mac, and it does indeed clear the focus from a text field…

[quote=75961:@Emile Schwarz]Stupid !

I want to clear the focus in a window (some ComboBox, actually and one TextArea), but I do not found how to.

I must change my glasses.

Help ![/quote]

I set focus to the Window when I want to clear the focus.

The Window.SetFocus method will clear the focus from the current control.[quote]Removes the focus from the control that currently has the focus, leaving no control with the focus. [/quote]

Under Cocoa, it does not work.

But ClearFocus does.

Have you tried setting focus to the window itself that contains the controls? Or. … create a nonvisible dummy control and setfocus to that one :slight_smile:

Here’s what we use in our app:

Sub ourClearFocus(theWindow as Window)
if theWindow = Nil then Return
ClearFocus
theWindow.SetFocus
End Sub

Thank for your answers.

In the Window Class page, I was not able to find ClearFocus. So that is why I searched elsewhere.