[Qt-creator] Script manager
Nicolas Arnaud-Cormos
nicolas at kdab.com
Thu Jan 14 10:47:33 CET 2010
On Thursday 14 January 2010 10:21:25 Eike Ziller wrote:
> Hi,
>
> [...]
> >
> > Im' thinking of a script like (that's just to give you an idea, it would
> > be more complicated):
> > currentEditor.replace("myCallback", "mySlot");
> >
> > actionManager.execute("CppEditor.SwitchHeaderToSource");
>
> Using the action manager for invoking operations is most probably not the
> best thing to do (though it would probably be the easiest to implement).
> E.g. specifically in this example, the "SwitchHeaderToSource" action is
> disabled if the editor doesn't also has keyboard focus. In other cases the
> actual action that would be invoked also depends on the current focus, or
> even a more abstract "context". This can be actions in completely
> different plugins (described in the API documentation of ActionManager).
> So you'd probably want a designated "script" method for switching
> header/source that has a more consistent behavior (in your case
> cpptoolsplugin.switchHeaderSource() would do the thing, because it works
> on the "current" editor. On the other hand we don't guarantee stable API
> (especially not for these kind of slots), so use at your own risk :)
That's not really a solution either, I don't want to re-write the script every
time I change the Qt Creator version.
Let's create an interface available from the script, and which called the
cpptoolsplugin.switchHeaderSource(). That will limit the available actions to
the one I've written in the interface, but at least I can garantee a stable
API for the scripts.
Thanks,
Nicolas
--
Nicolas Arnaud-Cormos | nicolas at kdab.com | Software Ingeneer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
More information about the Qt-creator-old
mailing list