Page 1 of 1

[Solved] Basic - Python? / Intercept context menu

PostPosted: Thu Jan 21, 2016 4:34 pm
by sng
Hi all

I have a writer extension I would like to intercept the context menu and add a submenu with a number of items

I have found this basic code, which can add an item on the context menu, but no submenu.

Then I remembered hanya's example called InterceptContextMenu, which is in python, and i believe i can make it add a submenu.

I have copied the code to a file called, but the thing is that i cannot "activate" it from within the extension. I tried adding to the manifest.xml:

Code: Select all   Expand viewCollapse view
<manifest:file-entry manifest:media-type="application/;type=Python" manifest:full-path=""/>

but when i try to install it i get an error (I don't have it right now but i can get it if needed).

How do i activate this code in the extension?

Re: Basic - Python? / Intercept context menu (add submenu)

PostPosted: Fri Jan 22, 2016 2:05 pm
by sng
I have managed to solve it myself :D

I have included the code

Code: Select all   Expand viewCollapse view
controller = doc.getCurrentController()

within a python function in my file presented in my previous post Auto execute BASIC macro from python

It was that easy :crazy:

This proves that i'm hopeless with python (but at least i'm trying...)

Marked as solved

BTW, the code already creates a submenu so I'm pleased :bravo: