Mouse up function logic incomplete

From the book and your sample it reads

    override func mouseUp(theEvent: NSEvent)
    {   println("mouse up click count: \(theEvent.clickCount)")
        if (theEvent.clickCount == 2) { randomize()
        pressed = false}
    }

Shouldn’t it read

    override func mouseUp(theEvent: NSEvent)
    {   println("mouse up click count: \(theEvent.clickCount)")
        if (theEvent.clickCount == 2) && pressed { randomize()
        pressed = false}
    }

I agree that logic in book does not work as intended.

Yes, this is better than the logic shown in the book. I’ve been trying to recall – I think that at one point we had a challenge in this chapter that tasked the reader with fixing this. So I guess you have solved the hidden challenge? :slight_smile:

After trying it out, pressed still needs to be set to false no matter the click count, so this is the implementation I would suggest:

	override func mouseUp(theEvent: NSEvent) {
		println("mouseUp clickCount: \(theEvent.clickCount)")
		if theEvent.clickCount == 2 && pressed {
			randomize()
		}
		pressed = false
	}