If you only want the menu to appear when X ison the channel, i think the use of on active and a group will be best:
on *:active:#:{
if (X ison $active) && ($group(#Xpopup) == off) .enable #Xpopup
if (X !ison $active) && ($group(#Xpopup) == on) .disable #Xpopup
}
#Xpopup off
menu channel {
example:/echo -a example
}
#Xpopup end
Something along those lines maybe.
Might also want to add a check to make sure you are on the right network too.