Hi all,
REALbasic 2007r1 / Mac OS X 10.4.8
I have a window with only one Control, a Canvas. Its Behavior's AcceptFocus
property is set to True.
By click I want to be able to set / unset the focus. In that Canvas MouseDown
Event I placed:
// Toogle the focus ring
Dim theCanvas As Canvas
// Compute if the Focus is set to a Canvas
If Self.Focus IsA Canvas Then
// Cast Canvas Control who have the Focus
theCanvas = Canvas(Self.Focus)
End If
// Clears or set the Focus
If theCanvas = Me Then
// Ask the Window to clear the focus
ClearFocus
Else
// Ask the Canvas to set the focus
Me.SetFocus
End If
Question #1:
Is this correct coding ?
[The code works (on Mac OS X) as I expected]
Question #2:
After reading carefully my code, it appears to me that:
a. Why do I not place the second if group in the first if like in:
// Toogle the focus ring
Dim theCanvas As Canvas
// Compute if the Focus is set to a Canvas
If Self.Focus IsA Canvas Then
// Cast Canvas Control who have the Focus
theCanvas = Canvas(Self.Focus)
// Clears or set the Focus
If theCanvas = Me Then
// Ask the Window to clear the focus
ClearFocus
Else
// Ask the Canvas to set the focus
Me.SetFocus
End If
End If
But it only allow to me to clear the focus, then Self.Focus is no more Canvas
(Nil or Undefined value or...)
The following code works, but I feel some trouble with it (which trouble? I do
not know):
// Toogle the focus ring
Dim theCanvas As Canvas
// Compute if the Focus is set to a Canvas
If Self.Focus IsA Canvas Then
// Cast Canvas Control who have the Focus
theCanvas = Canvas(Self.Focus)
If theCanvas = Me Then
// Ask the Window to clear the focus
ClearFocus
End If
Else
// Ask the Canvas to set the focus
Me.SetFocus
End If
Question #3:
To clears the Focus from the Canvas, I have to use a Window command -
ClearFocus - and to set the Focus to the canvas, I have to use a Canvas command
- Me.SetFocus - ; where the code consistency ?
[If I use an EditField comparison, I would say:
to set Bold, I use an EditField Command and to unset Bold, I have to use a
Window Command!
Specious comparison because there is Bold and SelBold;; however, you can see
the point]
Emile
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>