Hi all,
REALbasic 2006r2 Commercial Pro
Mac OS X 10.4.6 (tested on that OS)
I wanted to be able to set / unset the focus of a Canvas using a click:
Click = Set Focus (if the focus is not set)
Click = Clear Focus (if the focus is set)
and then I - naively - try the following code and get the same answer...
"This method doesn't return a value."
Try #1:
// Toogle the current Focus (value)
Me.SetFocus = Not Me.SetFocus
Try #2:
// Toogle the current Focus (value)
If Me.SetFocus Then
Me.SetFocus = False
Else
Me.SetFocus = True
End If
I had in mind the EditField 'Toogle' Methods while I wrote the 'try #2'
code (see above).
OK, REALbasic does not accept that syntax - yet ? - but this seems to me
the way to go...
I have a new idea:
a. Add a Window Property (gwIsCanvasFocus for example),
b. Set the focus to False in Canvas1.Open,
c. And in Canvas1.Click make the "toogle" depending on the
gwIsCanvasFocus value ...
I can also use the Window Focus As RectControl Method... Here I am:
// Toogle the Focus (value)
If Canvas(Self.Focus) = Me Then
// Clears the focus
ClearFocus
Else
// Set the focus to the Canvas object
Me.SetFocus
End If
BTW: even if the above code is REALbasic 200x only, I like it; I prefer
this one ;)
It's funny how sometimes the most obvious is... wrong (the same remark
exists, but with a different end!)
What is your feeling on the two tries (#1 and #2) and 'my solutions" ?
[especially the one who casts the Window Focus' RectControl]
Emile
PS: Read my other mail about the embedded language reference and the
Self.Focus Property.
Now, what I can name "my best code" is:
// Toogle the current Focus (value)
If Canvas(Self.Focus) = Me Then
// Clears the focus from the Canvas (this Canvas)
Self.Focus = Nil
Else
// Set the focus to the Canvas (this Canvas)
Self.Focus = Me
End If
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>