Controlling mechanically-operated bolts by electro-magnetically-operated detents