ToolBarManager的问题

来源:互联网 发布:php网页游戏源代码 编辑:程序博客网 时间:2024/06/05 05:05

It's difficult to tell from your question, but it sounds like you may be attempting to add a ControlContribution to the toolbar and returning a Button. This would make the button on the toolbar appear like a native button like you seem to be describing. This would look something like this:

IToolBarManager toolBarManager = actionBars.getToolBarManager(); toolBarManager.add(new ControlContribution("Toggle Chart") {     @Override     protected Control createControl(Composite parent)     {         Button button = new Button(parent, SWT.PUSH);         button.addSelectionListener(new SelectionAdapter() {         @Override         public void widgetSelected(SelectionEvent e) {                 // Perform action             }         });      } }); 

Instead you should add an Action to the toolbar. This will create a button on the toolbar that matches the standard eclipse toolbar buttons. This would look something like this:

Action myAction = new Action("", imageDesc) {     @Override     public void run() {         // Perform action     } };  IToolBarManager toolBarManager = actionBars.getToolBarManager(); toolBarManager.add(myAction);