New topic: 

Subclasses and Me Self and Parent Clarificaton needed

<http://forums.realsoftware.com/viewtopic.php?t=41039>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        harvey          Post subject: Subclasses and Me Self and Parent 
Clarificaton neededPosted: Mon Oct 17, 2011 10:33 am                         
Joined: Fri Apr 16, 2010 2:21 am
Posts: 24                Hi all,

I want to detect changes that the user made in a the textfield. I know about 
SelChange, but this doesn't suit my needs as it could fire several times while 
in the end the text is changed back to the original content. I want to prevent 
the user from closing windows with unsaved content. This should be checked only 
once when closing the window.
So I made two subclasses, one of Window and one of TextEdit. The Window 
subclass has an additional Property 'Tainted', the TextEdit box has an 
additional property 'InitialValue' which is set in the Open Event of the 
subclass by the code
Code:Me.InitialValue = Me.Text
further it has the following code in the LostFocus Event:
Code:If Me.Text <> Me.InitialValue then
  Self.Tainted = True
else
  Self.Tainted = False
End If

This doesn't work. If I set the same code into the LostFocus event of a 
TextEdit field on a window it works as expected. I understand that Self is 
referencing the subclass, not the window. Is there a way to code this to work 
directly from the subclass?

Otherwise I would have to put the code into every TextEdit box which makes the 
subclass obsolete...

Harvey      
_________________
Linux is like a wigwam: No Gates, no Windows and an Apache inside  
                             Top                timhare          Post subject: 
Re: Subclasses and Me Self and Parent Clarificaton neededPosted: Mon Oct 17, 
2011 11:13 am                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 10288
Location: Portland, OR  USA                You have to use the Window property 
and check whether it is your special window subclass.
Code:if window ISA myWindowSubclass then
 myWindowSubclass(window).Tainted = true
end

I very rarely use 'me' or 'self' in a subclass, as it is unnecessary and 
potentially confusing.  I reserve the use of 'me' and 'self' for instances on a 
window, where such use is necessary and the distinction is clear.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to