Sorry, was wrong with my statement. ClearFocus is a global method. Have you tried calling ClearFocus() and on the next line Self.SetFocus() so the focus is set to the window?
My code adds the focus, then add the user reports as appropriate, but does not change the Focus status. The used code have been greatly modified before I share it.
Note that I forgot about ClearFocus probably because we do not have to use it anymore ?
I even checked:
[code]If Self.Focus.Name = Me.Name Then
// Me have the focus, so clear it
Self.Focus = Nil
Else
// Me does not have the focus, so set it
Self.Focus = Me
End If[/code]
From memory, so the code may not work, but you see what I meant.
[quote=122801:@Emile Schwarz]My code adds the focus, then add the user reports as appropriate, but does not change the Focus status. The used code have been greatly modified before I share it.
Note that I forgot about ClearFocus probably because we do not have to use it anymore ?
I even checked:
[code]If Self.Focus.Name = Me.Name Then
// Me have the focus, so clear it
Self.Focus = Nil
Else
// Me does not have the focus, so set it
Self.Focus = Me
End If[/code]
From memory, so the code may not work, but you see what I meant.[/quote]
Apparently, what you want to do is each time you click on the canvas, it sets or remove the focus.
I tried to run your code, and encountered several issues :
Self.Focus = Nil does not remove the focus from the canvas. Clearfocus does.
When no control has the focus, Self.Focus.Name becomes nil which triggers a nil exception
Self.Focus = Me does not set the focus to the canvas. Me.Setfocus does.
Instead of Self.Focus.Name, you may want to use a boolean window property to keep track of the current canvas focus state.