Dictionary.com
Thesaurus.com

have all one's buttons

Idioms  
  1. Also, have all one's marbles. Be completely sane and rational. For example, Grandma may be in a wheelchair, but she still has all her buttons, or I'm not sure he has all his marbles. These slangy expressions date from the mid-1800s, as do the antonyms, meaning “become (or be) mentally deficient.”