Add keyevent to switch ViewPart under IPageLayout

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 03:54:07

问题


how to assign key for switch focus on different viewpart??

example: (press "SWT.F7" to focus on viewpartA, "SWT.F8" to focus on viewpartB)

public class UserPerspective implements IPerspectiveFactory{
    ......
    ......
    public void createInitialLayout(IPageLayout layout){
        final IFolderLayout leftPanel = layout.createFolder(......);
        leftPanel.addView(viewpartA.ID);

        final IFolderLayout rightPanel = layout.createFolder(......);
        rightPanel.addView(viewpartB.ID);
    }
}

回答1:


You can use the following key bindings. Read the documentation for the sequence carefully - it is a little tricky :-)

The value attribute below is the ID for your target view.

<extension
      point="org.eclipse.ui.bindings">
   <key
         commandId="org.eclipse.ui.views.showView"
         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
         sequence="F6">
      <parameter
            id="org.eclipse.ui.views.showView.viewId"
            value="com.rcpcompany.so.ed.view">
      </parameter>
   </key>
   <key
         commandId="org.eclipse.ui.views.showView"
         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
         sequence="SHIFT+F6">
      <parameter
            id="org.eclipse.ui.views.showView.viewId"
            value="com.rcpcompany.so.ed.view1">
      </parameter>
   </key>
</extension>


来源:https://stackoverflow.com/questions/7062132/add-keyevent-to-switch-viewpart-under-ipagelayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!