Re: [Inkscape-devel] [Inkscape-user] Assign hot keys to specific actions?
On 11/7/06, Bryce Harrington <bryce@...961...> wrote:
Bryce, the file to edit for remapping keys is called share/keys/default.xml.
Can you put a note about this into the Tips and Tricks tutorial or the Keys document?
OK, I will add a note.
As for the .rc file, would anyone object if I just delete it? It doesn't look like it's being used.
Well, units.xml was something Jon Cruz started after I implemented the units stuff using the units.txt file. The units.txt file is pretty easy to edit and has worked adequately, but I can see why some people might want it in xml. Unfortunately, the units.xml stuff never actually worked, and it wasn't clear what the plan was for making it work, so it's just been there disabled all this time.
JonCruz, will you object to removing units.xml?
Then would it be possible to have a shortcut key that does vertical and horizontal center alignment?
What needs to be done is creating a _verb_ that does this. After that, adding it to menu or assigning a key to it will be trivial. There are many things that Inkscape can do in principle, but not through a verb, and these things should be verbified. By the way, verbification is pretty simple thing to do, so it's a good work for novice coders. Just review verbs.h and verbs.cpp, they're pretty self-explanatory.
For example just recently, I verbified the select next/select prev actions, bound to Tab/Shift+Tab, and as a result these keys now work in all tools and not only Selector/Node as before.
Oh, there is also a bug in text centering - write some text, then change it from left-aligned to center-aligned. The text then moves from its current position to half its width to the left. This bug has been there since Sodipodi days...
It's not really a "bug". Inkscape just needs to recalculate the anchor point based on the bounding box of the text, in addition to changing alignment. More like a missing feature (worth a RFE).
On Tue, Nov 07, 2006 at 04:20:31PM -0400, bulia byak wrote:
As for the .rc file, would anyone object if I just delete it? It doesn't look like it's being used.
No objection from me. Looks like I was the one who added it originally, and no one else has done anything with it.
By the way, verbification is pretty simple thing to do, so it's a good work for novice coders. Just review verbs.h and verbs.cpp, they're pretty self-explanatory.
For example just recently, I verbified the select next/select prev actions, bound to Tab/Shift+Tab, and as a result these keys now work in all tools and not only Selector/Node as before.
Hmm, could you provide a bit more detail? verbs.h looks straightforward enough, but looking at verbs.cpp it'd take a bit of time to nut out what would need to be done there.
I've been thinking that we should give added visibility to areas like this where novice coders could quite easily get involved and make a difference to the codebase. I know there are a large number of people who would like to help but who are not confident in being able to code. So tasks like this that can quite easily be boiled down to sort of a 'paint by numbers' procedure could be things we may be able to farm out more, like we've been able to successfully do with translations.
Maybe just explain what steps were involved in doing the select action changes you did, along with any tips on things to watch out for?
Bryce
On 11/7/06, Bryce Harrington <bryce@...961...> wrote:
Hmm, could you provide a bit more detail? verbs.h looks straightforward enough, but looking at verbs.cpp it'd take a bit of time to nut out what would need to be done there.
OK, here's an illustrated guide:
First, add IDs for new verbs to verbs.h:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/verbs.h?r1=132...
The place of the ID in the list determines to which group it belongs (EditVerbs, FileVerbs, etc) - however, this is pretty arbitrary, so don't sweat if you can't find a perfect group for your verb, just use whichever makes most sense.
Then in verbs.cpp, fill in the verb structure with the name, description, action ID, etc; also in the same file, write the actual commands that the verb will do, in a switch case in one of ::perform methods:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/verbs.cpp?r1=1...
As you see, these verbs do different things depending on which tool you are in. Before verbification, this was coded into tool context files, and now we can remove that:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/node-context.c... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/select-context... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/draw-context.c... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/draw-context.c...
(the last one required writing two functions that will be called by the verb).
Now assign the keys to the newly created verbs:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/keys/inkscap...
and then copy inkscape.xml to default.xml.
Note: even if you are not assigning any key, you MUST list the new verb in inkscape.xml, using a <bind> without a key. Not only this file is a keymap, but it's also a reference for keymap writers, so it must have all verbs, assigned or not.
If you added a shortcut which didn't exist before, update also doc/keys.xml.
If you want the new verb in the menu, edit menus-skeleton.cpp and insert it there in an appropriate place.
Also review the other keymaps to see if you can assign the new verb to some key that would make sense. So in adobe-illustrator.xml, I assigned the new verbs to Alt+Ctrl+[], which seems to be the same thing according to the comments:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/keys/adobe-i...
Finally update the release notes:
http://wiki.inkscape.org/wiki/index.php?title=ReleaseNotes045&diff=8842&...
Ask me if you have any questions.
On Tue, Nov 07, 2006 at 10:18:31PM -0400, bulia byak wrote:
On 11/7/06, Bryce Harrington <bryce@...961...> wrote:
Hmm, could you provide a bit more detail? verbs.h looks straightforward enough, but looking at verbs.cpp it'd take a bit of time to nut out what would need to be done there.
OK, here's an illustrated guide:
Cool, this is perfect! I've turned it into a wiki page here:
http://wiki.inkscape.org/wiki/index.php/AddingInterfaceVerbs
It would be nice to have one or two novice coders have a shot at this process and see if any clarification is needed. Anyone up to giving it a shot? My guess is there may be some uncertainty in how to figure out the changes to verbs.cpp.
Bryce
First, add IDs for new verbs to verbs.h:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/verbs.h?r1=132...
The place of the ID in the list determines to which group it belongs (EditVerbs, FileVerbs, etc) - however, this is pretty arbitrary, so don't sweat if you can't find a perfect group for your verb, just use whichever makes most sense.
Then in verbs.cpp, fill in the verb structure with the name, description, action ID, etc; also in the same file, write the actual commands that the verb will do, in a switch case in one of ::perform methods:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/verbs.cpp?r1=1...
As you see, these verbs do different things depending on which tool you are in. Before verbification, this was coded into tool context files, and now we can remove that:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/node-context.c... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/select-context... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/draw-context.c... http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/draw-context.c...
(the last one required writing two functions that will be called by the verb).
Now assign the keys to the newly created verbs:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/keys/inkscap...
and then copy inkscape.xml to default.xml.
Note: even if you are not assigning any key, you MUST list the new verb in inkscape.xml, using a <bind> without a key. Not only this file is a keymap, but it's also a reference for keymap writers, so it must have all verbs, assigned or not.
If you added a shortcut which didn't exist before, update also doc/keys.xml.
If you want the new verb in the menu, edit menus-skeleton.cpp and insert it there in an appropriate place.
Also review the other keymaps to see if you can assign the new verb to some key that would make sense. So in adobe-illustrator.xml, I assigned the new verbs to Alt+Ctrl+[], which seems to be the same thing according to the comments:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/keys/adobe-i...
Finally update the release notes:
http://wiki.inkscape.org/wiki/index.php?title=ReleaseNotes045&diff=8842&...
Ask me if you have any questions.
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org
On 11/8/06, Bryce Harrington <bryce@...961...> wrote:
Cool, this is perfect! I've turned it into a wiki page here:
http://wiki.inkscape.org/wiki/index.php/AddingInterfaceVerbs
Thanks!
A couple words on what might be good candidates for verbification:
- anything that all tools do but which is still not a verb, such as Esc for deselection
- anything that is needed for more complete keymaps emulating other editors, for example as listed here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1532158&gro...
- any global action (i.e. which is not limited to some tool's context) for which it just makes sense to have a quick shortcut, even if it is already available via a dialog, a tool control, or some other more complicated way (example: centering selected objects; increasing/decreasing blur/opacity/stroke width in selection, etc.).
On Wed, Nov 08, 2006 at 04:57:02AM -0400, bulia byak wrote:
On 11/8/06, Bryce Harrington <bryce@...961...> wrote:
Cool, this is perfect! I've turned it into a wiki page here:
http://wiki.inkscape.org/wiki/index.php/AddingInterfaceVerbs
Thanks!
A couple words on what might be good candidates for verbification:
- anything that all tools do but which is still not a verb, such as
Esc for deselection
- anything that is needed for more complete keymaps emulating other
editors, for example as listed here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1532158&gro...
- any global action (i.e. which is not limited to some tool's context)
for which it just makes sense to have a quick shortcut, even if it is already available via a dialog, a tool control, or some other more complicated way (example: centering selected objects; increasing/decreasing blur/opacity/stroke width in selection, etc.).
Got it. Feel free to add more ideas to that page.
Bryce
On 11/7/06, Bob Jamison <rwjj@...127...> wrote:
I assume that you don't mean src/inkscape.rc , which we use for linking the .exe
No, I referred to share/ui/keybindings.rc
participants (3)
-
Bob Jamison
-
Bryce Harrington
-
bulia byak