Editor Menu Item open Window

I have a c# script which creates a menu item in the editor. How would I make it so that when clicked it opens a window with a textbox and OK button, then uses the text boxes text in the script?

It’s all explained here. This script should serve as an example of how to use a textbox and a button. A textbox will appear when you select something in the hierarchy, you can then change the name and press ok to apply the changes.

class MyWindow extends EditorWindow 
{
    @MenuItem ( "Window/My Window" )
    static function ShowWindow () 
    {
        EditorWindow.GetWindow ( MyWindow );
    }
	
	var newName : String;
	
    function OnGUI () 
    {
		GUILayout.Label( "Select an object in the hierarchy view" );
		if( Selection.activeGameObject )
		{
			newName = EditorGUILayout.TextField( "Object Name: ", newName );
			if( newName == "" )
			{
				newName = Selection.activeGameObject.name;
			}
            if( GUILayout.Button( "Ok" ) )
            {
        	    Selection.activeGameObject.name = newName;
            }
		}
		else
		{
			newName = "";
		}
		
        
        this.Repaint();
    }
}

I need a help. I dont want my window to open via Menu. I want it to open on some event or a editor button click. Is it possible to do?
In short I dont want my window to become a menu Item.