| <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| --><mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.3" xml:lang="en" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd"> |
| <siteinfo> |
| <sitename>NetBeans Wiki</sitename> |
| <base>http://wiki.netbeans.org/Main_Page</base> |
| <generator>MediaWiki 1.15.1</generator> |
| <case>first-letter</case> |
| <namespaces> |
| <namespace key="-2">Media</namespace> |
| <namespace key="-1">Special</namespace> |
| <namespace key="0"/> |
| <namespace key="1">Talk</namespace> |
| <namespace key="2">User</namespace> |
| <namespace key="3">User talk</namespace> |
| <namespace key="4">NetBeans Wiki</namespace> |
| <namespace key="5">NetBeans Wiki talk</namespace> |
| <namespace key="6">File</namespace> |
| <namespace key="7">File talk</namespace> |
| <namespace key="8">MediaWiki</namespace> |
| <namespace key="9">MediaWiki talk</namespace> |
| <namespace key="10">Template</namespace> |
| <namespace key="11">Template talk</namespace> |
| <namespace key="12">Help</namespace> |
| <namespace key="13">Help talk</namespace> |
| <namespace key="14">Category</namespace> |
| <namespace key="15">Category talk</namespace> |
| </namespaces> |
| </siteinfo> |
| <page> |
| <title>DevFaqRebindingKeys</title> |
| <id>7448</id> |
| <revision> |
| <id>26232</id> |
| <timestamp>2009-11-06T15:58:58Z</timestamp> |
| <contributor> |
| <username>Admin</username> |
| <id>1</id> |
| </contributor> |
| <text xml:space="preserve">__NOTOC__ |
| ===Can I bind one key to more than one action?=== |
| |
| |
| The simple answer is no: The |
| global keymap (get <tt>Keymap</tt> from Lookup) |
| is a master keymap for the whole application, and like all keymaps accepts |
| only one action per binding. If you want multiple actions to be |
| run, you must create a "wrapper" action that runs them all in turn |
| (or in parallel). |
| |
| ====What about binding a key differently in different windows?==== |
| |
| You may bind a key differently in different windows, by using |
| the normal Swing techniques of binding keystrokes to components. In |
| fact, some work went into implementing the global map so that it |
| would work across arbitrary components; it is overridden by local |
| bindings, such as navigation keys on dialogs or Explorer trees, or |
| various editing keys in the Editor. |
| |
| Before you bind a key performing a high-level specific action, |
| such as '''Ctrl-N''' for '''New File''', |
| to a different action in a local component (e.g. window), think |
| carefully whether this is really the right approach. In many cases |
| the UI of your extension and the IDE as a whole will be better |
| served by leaving the key binding alone, and instead providing an |
| appropriate cookie, action performer, or other callback associated |
| with your component, so that the action (and potentially other code |
| unknown to you) will function naturally. If you must rebind a |
| global key, consider whether it is appropriate to determine the |
| current key binding for the action (if any) in the global keymap, |
| and use this keystroke to rebind - so user customizations will |
| remain intact. |
| |
| <tt>CallbackSystemAction</tt>s such as '''Find''' or |
| '''Delete''' can easily have different bindings in each component, |
| using <tt>ActionMap</tt>.</text> |
| </revision> |
| </page> |
| </mediawiki> |