A man who lifted a gun up to a shop worker in Leeds city centre and pulled the trigger has been detained in hospital.