You've inverted the logic here (event != down -> event == down), which is probably the cause of the build palette bug.