问题
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