| // |
| // 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. |
| // |
| |
| = DevFaqRebindingKeys |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| :keywords: Apache NetBeans wiki DevFaqRebindingKeys |
| :description: Apache NetBeans wiki DevFaqRebindingKeys |
| :toc: left |
| :toc-title: |
| :syntax: true |
| |
| === Can I bind one key to more than one action? |
| |
| The simple answer is no: The |
| global keymap (get `Keymap` 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. |
| |
| `CallbackSystemAction`s such as *Find* or |
| *Delete* can easily have different bindings in each component, |
| using `ActionMap`. |
| |
| === Apache Migration Information |
| |
| The content in this page was kindly donated by Oracle Corp. to the |
| Apache Software Foundation. |
| |
| This page was exported from link:http://wiki.netbeans.org/DevFaqRebindingKeys[http://wiki.netbeans.org/DevFaqRebindingKeys] , |
| that was last modified by NetBeans user Admin |
| on 2009-11-06T15:58:58Z. |
| |
| |
| *NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed. |