- Timestamp:
- 07/31/08 21:19:39 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Tests/220-delegates-etc/120-events/300-raise.cobra
r1560 r1566 5 5 event click as ClickHandler 6 6 7 def receiveMouseClick 7 def receiveMouseClick1 8 8 # pretend it's always in our bounds and we're enabled 9 # raise .click(this, EventArgs()) 10 raise .click, this, EventArgs() 11 # raise .click, EventArgs() 12 # raise .click 13 # raise .click, this 9 raise .click, this, EventArgs() # .warning. unnecessary "this" 10 11 def receiveMouseClick2 12 raise .click, EventArgs() 13 14 def receiveMouseClick3 15 raise .click, this # .warning. unnecessary "this" 16 17 def receiveMouseClick4 18 raise .click 14 19 15 20 … … 18 23 shared 19 24 20 var _didClick = false 25 var _butt as Button 26 var _clickCount = 0 21 27 22 28 def main 23 butt = Button() 29 butt = _butt = Button() 30 24 31 listen butt.click, ref .handleClick 25 assert not _didClick 26 butt.receiveMouseClick 27 assert _didClick 32 assert .clickCount == 0 33 34 butt.receiveMouseClick1 35 assert .clickCount == 1 36 37 butt.receiveMouseClick2 38 assert .clickCount == 2 39 40 butt.receiveMouseClick3 41 assert .clickCount == 3 42 43 butt.receiveMouseClick4 44 assert .clickCount == 4 45 46 get clickCount from var 28 47 29 48 def handleClick(sender as Object, args as EventArgs) 30 _didClick = true 49 assert sender is _butt 50 assert (args to dynamic?) inherits EventArgs 51 _clickCount += 1
