I think the real question is why didn't it fail in r2? You should do one of the following:
If Self.Focus = Me Then // you don't need to cast for this comparison or at least If Self.Focus Isa Canvas Then If Canvas(Self.Focus) = Me Then // make sure you've got a legal cast HTH, Tim > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Emile > Schwarz > Sent: Saturday, July 15, 2006 5:14 AM > To: REALbasic Network Users Group > Subject: IllegalCastException with REALbasic 2006r3 > > > New in REALbasic 2006r3 [Mac OS X 10.4.7] > > The following line gets an error in r3, but works fine in r2: > > If Canvas(Self.Focus) = Me Then > > > but the corrected lines works OK: > > Dim theCtrl As Control > > // Get the Control who have the focus > theCtrl = Self.Focus > > // Toogle the current Focus (value) > If Canvas(theCtrl) = Me Then > > > The error was IllegalCastException. > > > The code is in Canvas1.MouseDown... > > > > Why ? > > > > IllegalCast Exception follow-up > ------------------------------- > > REALbasic 2006r3 Commercial Pro > Mac OS X 10.4.7 > > The newly changed code does not works too, now, several minutes after the > previous change: > > Dim theCtrl As Control > Dim ChoosedColor As Variant > > // Get the Control who have the focus > theCtrl = Self.Focus > > // Toogle the current Focus (value) > If Canvas(theCtrl) = Me Then > > > and once I have added the second Dim line (and code below the If > .../... Else If > block! > > What happens ? > > > I've made a simple change in the code: > > Dim theCtrl As Control > Dim myCanvas As Canvas > Dim ChoosedColor As Variant > > // Get the Control who have the focus > theCtrl = Self.Focus > > // Toogle the current Focus (value) > myCanvas = Canvas(theCtrl) > If myCanvas = Me Then > > > How many times will that work ? > > Emile > _______________________________________________ > 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> > > _______________________________________________ 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>
