[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: MultpageEditor Accelerator problem

Hi Ron,

I run into quite the same problem earlier this week. I don't know if the
described behaviour is a bug or if it is intended and we just do not
understand how to handle it correctly. Whatsoever, I finally implemented
the following work-around:

private void setCopyPasteBinding(boolean routeToEditor) {
  IKeyBindingService bind = getEditorSite().getKeyBindingService();
  if (!routeToEditor) {

    // Stop actions from being sent to the embedded text editor.
    bind.unregisterAction(
      editor.getAction(ITextEditorActionConstants.CUT));
    bind.unregisterAction(
      editor.getAction(ITextEditorActionConstants.COPY));
    bind.unregisterAction(
      editor.getAction(ITextEditorActionConstants.PASTE));
    bind.unregisterAction(
      editor.getAction(ITextEditorActionConstants.SELECT_ALL));
    bind.unregisterAction(
      editor.getAction(ITextEditorActionConstants.DELETE));
  } else {
    // Reconnect actions with text editor on page 0.
    bind.registerAction(
      editor.getAction(ITextEditorActionConstants.CUT));
    bind.registerAction(
      editor.getAction(ITextEditorActionConstants.COPY));
    bind.registerAction(
      editor.getAction(ITextEditorActionConstants.PASTE));
    bind.registerAction(
      editor.getAction(ITextEditorActionConstants.SELECT_ALL));
    bind.registerAction(
      editor.getAction(ITextEditorActionConstants.DELETE));
  }

  // Propagate changes.
  getActionBars().updateActionBars();
}

Call this whenever the displayed page changes, and COPY/PASTE should work
again. At least for me it does..

Good luck,

Tobias



Ron wrote:

> Hi All,

> I have a multi-page editor with two pages.  One page/tab holds a Graph
> editor, derived from GEF's GraphicalEditorWithPalette, and the other is an
> unmodified TextEditor.

> I have implemented Cut, Copy and Paste Action/Command combinations for the
> Graph editor.  I have made the necessary changes so that these actions are
> successfully and correctly invoked when one selects the corresponding menu
> item with the mouse.

> However, when an 'accelerator' key (e.g., Ctrl-C for Copy) is typed, the
> event is dispatched to the TextEditor - even when the Graph editor is
> active!

> Any thoughts on how I can fix this would be greatly appreciated.

> thanks,

> Ron