Am 27.02.2009 um 01:32 schrieb William Shank:
1) create Class1, a subclass of Canvas
create Class2, a subclass of Class1
in class2.mouseDown put: MsgBox "2"
now in class1.mouseDown put: MsgBox "1"
mouseDown in class2 is now italic. But you can use these classes, they
compile and msgbox the correct number.
That's _not_ how you should do this or you'll have strange problems
later. And even if it compiles in current versions of Rb, it is likely
to be broken in future releases. The correct way is to pass the event
to the subclass. To keep your example, do the following:
1) In Class1 create a new MouseDown event (Project -> Add -> Event):
MouseDown(x as Integer, y as Integer) as Boolean
2) Put the following code in the MouseDown event of Class1:
Function MouseDown(x as Integer, y as Integer) As Boolean
// This will pass the MouseDown event to Class2
if RaiseEvent MouseDown(x,y) then
// Class2 has handled the event
return true
end if
// You can add the code for the MouseDown event of Class1
here...
End Function
3) Put whatever code you want in the MouseDown event of Class2, but
make sure you return 'true' at the end. If you don't return 'true',
the rest of the code in the MouseDown event of Class1 will also be
executet.
ps. I find it weird that situation 1) does compile and overrides as
expected.
This is definitely a bug.
Gruß
Christian
----------------------------------------
Christian Dorn
realbasic {a} online.de
REALbasic 2008.5-1 Pro
iMac 3.06 GHz Intel Core 2 Duo, 4 GB RAM
PowerMac G5 2x2GHz, 1.5 GB RAM
Mac OS X 10.5.6
----------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|