How to edit/replace menu on multi line?

I would really like to have a custom popup menu on a multi-line contol.

I am exploring building an extension that operates similar to Python in MS Excel. I have had success with several steps needed to make this happen.

It seems to me a control (custom multi line text) would be needed to input python. The results of the python input would somehow be relayed to the revelent calc cell(s). The control would be anchored to the cell and thus mimic cell contents.

I want to trigger a popup dialog or something that can be opened to input or modify Python code.
Idealy this could be done by hitting a keyboard shortcut or Right clicking and choosing Edit on the control.

Any thoughts?