[texworks] do scripts support context menus?
Marco Canini
marco.canini at gmail.com
Wed May 25 13:25:27 CEST 2011
Paul,
thanks for the info. Perhaps something that would still satisfy me is
the ability to associate a shortcut to a script. Can that be done?
Cheers
On Wed, May 25, 2011 at 1:25 AM, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Hi Marco,
>
> AFAIK at present there is no way to directly use an altered context
> menu with scripting, but it has been sort of potentially flagged as a
> possibility.
>
> You may be able to connect mouse clicks to an editor window using
> hooks, but I do not know how stable that would be, and Stefan provided
> notes in November 2010, that suggested that meanwhile those parts of
> the Tw scripting api should be left alone - you can look through
> http://twscript.paulanorman.com/docs/html/TexWorksQtScripting.htm and
> the chm download version http://twscript.paulanorman.com/docs/ for
> "TeXworks Script Api functions and properties"
>
> There was a detailed discussion back in April last year including this...
>
>>
>> 5) Introduce a new script type ("multi", "mixed", ... ideas welcome)
>> that defines only functions. There is one special function (e.g.
>> init())
>> that gets called when the TWScript object is created. Its purpose
>> is to
>> register menu items, toolbar items, hooks, ... (whatever comes to
>> mind).
>> Each of them gets connected to a function provided by the script.
>>
>>
>
> http://tug.org/mailman/htdig/texworks/2010q2/002685.html
>
> And another discussion involving me where adding the whole script menu
> to the rightcontext menu was mooted.
>
> <Just_some_thoughts>
>
> Perhaps there could be new part of script header (or just altering the
> current // Context: operatoin) that indicates which menus a script
> should appear in?
>
> Then using the same kind of business logic as presntly, it and its
> directory folder only appear in menus indicated as is currently done?
> (Even if you have a directory under scripts it is not added to the
> Script menu unless it has a valid Tw .qt or .js .py .lua in it.)
>
> Possibly something like altering // Context: current options to have
> the current settings to continue to refer to their current main menu
> locations (supports legacy scripts), and instead of C++ looking for a
> single option here currently
>
> PDFDocument or TeXDocument
>
> It could look for one or more collection members instead and apply all
> choices present, perhaps two additional memebers of such a collection
> - PDFDocument-ContextMenu and TeXDocument-ContextMenu
>
> So the script header portion could sometimes look like this for some reason ...
>
> // Context: TeXDocument TeXDocument-ContextMenu PDFDocument-ContextMenu
>
> And so on.
>
> </Just_some_thoughts>
>
> You may find from what Stefan and Jonathan have already flagged in
> older threads, that there are better plans - much more wide sweeping
> as well (positioned menu subtrees buttons toolbars etc ...).
>
> Paul
>
>
> On 25 May 2011 02:22, Marco Canini <marco.canini at gmail.com> wrote:
>> Hello,
>>
>> I would like to make a script that when I right click on a \input{...}
>> command it shows an 'Open file' in the context menu. Is that doable
>> with the current API (0.4 r759)?
>> I reckon implementing the same functionality triggered by CTRL + left
>> click or double click on the \input{...} command would be more complex
>> and the API doesn't support that. Am I right?
>>
>> Thanks
>>
>> --
>> Marco Canini
>>
>
--
Marco Canini
More information about the texworks
mailing list