Janice Galloway said pianist Graeme McNaught, 54, arrived uninvited at her home wearing bright clothes and with dyed blonde hair.
McNaught is alleged to have told Miss Galloway he was to "walk into the water" and wanted to take the couple's son James with him.
He is on trial at Hamilton and faces 10 charges of placing Ms Galloway in a state of fear and alarm. He has denied all charges.
Ms Galloway, 58, the author of The Trick Is To Keep Breathing, told a jury that McNaught, of Mount Vernon, Glasgow, had come to her former home in Glasgow in 1997.
Giving evidence, she said: "It was frightening. He said he was going to be the King of Scotland. I assumed it was a joke but he seemed hurt. He went on at length that he had to conduct some sort of ceremony on a beach but he had to walk into water and wanted to take James with him for that purpose.
"James was five at the time, he was upstairs and I hoped he could not hear anything. The threatening stuff was directed at my son and I felt I had to do something. I had never seen Graeme so agitated before."
Ms Galloway, of Uddingston, Lanarkshire, said she contacted police and a psychiatrist was also called - but McNaught fled before the doctor arrived.
The trial before Sheriff Ray Small continues.