SetFocus on cocoa builds

Window.SetFocus seems not to work on cocoa builds.
Do I miss something?

What are you awaiting ? A Focus ring around the window ?

Note that TextArea (TextField ?) does not have Focus ring… native in Cocoa (2013r4.1).

[quote=67106:@Michael Thaler]Window.SetFocus seems not to work on cocoa builds.
Do I miss something?[/quote]

You may use window.show instead to make the window active (even if it is already displayed), but I checked, window.setfocus does work. Difficult to know what you mean by “does not work” without more details.

Let’s say I have a window with just a TextField.
At the MouseDown Event of the window I wrote SetFocus

If I click somewhere on the window I suspect the TextField looses the focus.
But that does not happen. On carbon builds it does.

I suspect too, but I would wrote: ClearFocus instead of SetFocus; after all, it is what I want (clear the focus from the TextField).

Better, you can add the LostFocus Event to the TextField and place there Me.ClearFocus.

This advice was not tested before posting it.

Enter ClearFocus instead. Then when you click on the window background, it will clear the focus from the text field (or any other control that has the focus).

Hope this helps.

This has been tested :wink:

Yes - ClearFocus works.
I don’t know why, because the language reference says:

But I can live with that. :slight_smile:
Many thanks!

When changing top window, Cocoa does not change the focus on controls. This is convenient when you switch between windows and have a textfield focused where something has already been typed. When you activate the window again, focus picks up where it was, and you can continue typing from the point where you left.

Actually it does. If you clear the focus and come back to the window, the focus goes again to the TextField. That is not convenient…
But I can work around this.

Right now I am switching a huge application from carbon to cocoa. And this is really a lot of work.
But I will survive it :slight_smile:

Thanks again.
I may come back with new questions later… :wink:

You are welcome.