Dragwindow can only be called within a window callback

I tried to move GUI.DragWindow() to a separate function as a way to conditionally draw a stand-alone window depending on whether the GUI element was a child of another element. Although the drag window behavior works properly, Unity generates the following recurring error at runtime:

Dragwindow can only be called within a
window callback

Is there a reason why Unity claims it can’t handle the window callback calling another function?

        public delegate void AggregateDraw();
        AggregateDraw standaloneWindowContent;

        standaloneWindowContent = () =>
        {
            GUI.DragWindow();
        };

        public void Draw()
        {
            rect = GUI.Window(containerID, rect, DrawWindowContent, actionName);
        }       

        void DrawWindowContent(int id)
        {            
            standaloneWindowContent();           
        }

Well, where do you call your “Draw” method? That’s most likely the important part. When i copy& paste your code into my test project and call Draw from OnGUI everything works just fine without any error or warning.