Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Copy and paste problems in ToolBar Text widget
Copy and paste problems in ToolBar Text widget [message #558323] Sat, 11 September 2010 09:04 Go to next message
Andreas Scherer is currently offline Andreas Scherer
Messages: 6
Registered: September 2010
Junior Member
Hello,

I want to add in the Eclipse status line a new ToolBar containing a Text widget that supports full copy and paste functions. The creation of the ToolBar succeeds, but unfortunately the copy and paste actions are not handled by the Text widget of my ToolBar but by the active workbench part. That means that if for example the active workbench part is an editor, then I can select my Text widget, write text in it, but when pressing CTRL+P the content of the clipboard is inserted somewhere into the editor text instead of my widget.

My first fix tried to get the active workbench part, and in case it's an editor, get its action bars, and as soon as my Text widget gets the focus, set new global action handlers.
My second fix tried to call the handler service (IHandlerService), and as soon as my Text widget gets the focus, activate new handlers for the command ids (like org.eclipse.ui.edit.paste).

I also thought about changing what is active in my workbench window, but all these fixes did now work properly, so I tried another fix: I implemented a new command, defined it with the extension point org.eclipse.ui.commands, then I defined new key bindings for CTRL+C/V/X with extension point org.eclipse.ui.bindings, I defined a new context for my key bindings, and as soon as my Text widget gets the focus, I activate the context.

This solution works fine with copy and paste, but I see that there are more editor functions like CTRL+SHIFT+LEFT/RIGHT to select words, and such functions still do not work properly. It would be ok if these editor function would not work at all, but it is somehow weird that editing text in my Text widget and pressing CTRL+SHIFT+LEFT selects text somewhere else in the active editor.

What is the best solution for this problem?

Andreas
Re: Copy and paste problems in ToolBar Text widget [message #558544 is a reply to message #558323] Mon, 13 September 2010 12:40 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

See the IFocusService.

You can add your widget, and that will give it higher priority than the
active part. Then use that to add the handlers you wish.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Copy and paste problems in ToolBar Text widget [message #559191 is a reply to message #558544] Wed, 15 September 2010 21:37 Go to previous messageGo to next message
Andreas Scherer is currently offline Andreas Scherer
Messages: 6
Registered: September 2010
Junior Member
Thanks Paul for the response.

I have registered my Text widget now to the IFocusService, and with the default copy/paste/cut handlers activated these functions work as expected and without using a new context.

So far so good but there is still the problem with these text editor functions, like "select next word", that are not handled by my text widget but by the active editor.
Do I have to specify handlers for all the IDs listed in ITextEditorActionDefinitionIds, or is there a solution to at least disable the current editor handlers?

Andreas
Re: Copy and paste problems in ToolBar Text widget [message #559318 is a reply to message #559191] Thu, 16 September 2010 11:36 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The problem is that the activeEditor and activePart are both still valid
while you are in the text widget.

You can override anything you know about (provide an AbstractHandler
that returns isHandled()==false) but the rest will shine through.

That's one of the architectural problems with the 3.x Workbench.
Workbench windows and parts are active. Dialogs override keybindings.
But random controls don't effect the WorkbenchWindow state.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Copy and paste problems in ToolBar Text widget [message #559329 is a reply to message #559318] Thu, 16 September 2010 12:05 Go to previous message
Andreas Scherer is currently offline Andreas Scherer
Messages: 6
Registered: September 2010
Junior Member
ok, thanks again for the information Smile
Previous Topic:How to externalize strings for fragment's resources
Next Topic:Save dirty workbench in the background?
Goto Forum:
  


Current Time: Thu Oct 23 13:15:05 GMT 2014

Powered by FUDForum. Page generated in 0.02766 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software