Optimized buttonPressed.