Editor scripting, select a field

Hi, im making my first editor script. I want to make an my fields selectable, and when it is active i want a pop up window to show up.

Ive been trying to use Selection.activeGameObject like so

for(com in target.gameObjectsToModify)
{
    com=EditorGUILayout.ObjectField(com,GameObject,false,options);

    if(Selection.activeGameObject==com)//Create popup
}

This doesnt work, as i tried printing from the if statement. What is the proper way to get the selection of the field?

I made another script that extends EditorWindow for the pop up. Currently the popup never shows up ( im not using any conditionals currently). Lets say it does work, how can i link it to that if statement and create that popup when the field is selected?

Editor script executes only when object that this editor is created for is becomes selected

so, you should use EditorWindow to monitor selection changing using

and make whatever you want in this method.