|
|
|
Re: Turning on key bindings in an editor [message #334082 is a reply to message #334065] |
Mon, 19 January 2009 18:15 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
> Now I need to dynamically create bindings.
What are you trying to do (i.e. what behaviour do you expect your users
to see)? Normally, an RCP app can include the keys preference page and
allow users to change their keybindings (without having to code it
yourself). Changing keybindings is an expensive operation, and the API
is set up specifically to prevent people from using keybindings to
activate and de-activate commands.
> I can either play games
> surrounding the IBindingService, or I can fake out the preferences, or I
> can precreate all the possible bindings and then fiddle with handlers to
> turn them on and off, but I can't seem to just make a call to create a
> binding.
That's because the cost to fiddle around with bindings is much greater
than the cost to update commands with different handlers based on the
currently executing context (and that is what is designed into the system).
If you need to provide functionality like a keys preference page (and
can't include the preference page itself) then you need to code it like
the keys preference page (make changes to a local binding manager and
then save the bindings to the preference store). That's supported and
mostly API.
If you need to activate different behaviour for CTRL+8 depending on if
you are in an editor or a view, that's done by using
org.eclipse.ui.contexts and attaching different commands to those keys
in different contexts.
If you need the behaviour of a command to change depending on if you are
in an editor or a view (like copy in an editor gives text but copy in
the project explorer gives an IResource) the you use one keybinding, one
command, and multiple handlers.
Schemes are designed to never change. Context are designed to allow
different sets of keybindings to be swapped in depending on a major
change, like switching to a different view or editor. Handlers are
designed to be swapped in depending on the executing context.
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Powered by
FUDForum. Page generated in 0.04116 seconds