Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » using shortcuts wile in text widgets run Eclipse command instead of text behavior
using shortcuts wile in text widgets run Eclipse command instead of text behavior [message #332522] Fri, 24 October 2008 20:16 Go to next message
Eclipse UserFriend
Originally posted by: james.towers.siemens.com

Hi,

When we are in text widgets and use shortcut keys the bound Eclipse commands
run instead of expected text behavior. In text widgets we would like
copy/cut/paste/delete to work in a text like manner. If we are not in a
text widget we would like the commands run.

Currently if we select a model object in a Tree, position into a text field,
select some text, and use M1+C, we copy the model object instead of the
text. The outcome is worse if we do the same except use the delete key as
we delete the model object. We noticed that if no model objects are seleted
we get expected text behavior while in text fields.

We are using Eclipse 3.3 menus/commands/handlers. We have defined our own
context for key bindings.

We found the org.eclipse.ui.textEditorScope context and tried to use it in
our activeWhen clauses....make the handler active when we are not in a text
widget. We discovered that o.e.u.contexts.dialogAndWindow/window were
active even while in a text widget and o.e.u.textEditorScope was not.

I'm hoping there is good way for us to get text behavior while in text
widgets and command behavior while elsewhere. Below I show some snippets of
our handlers/contexts/keys using copy as an example...they are similar for
cut/paste/delete.

Thanks,
Jim

Handler:

<handler

class="HandlerClass"

commandId="org.eclipse.ui.edit.copy">

<activeWhen>

<iterate

ifEmpty="false">

<adapt

type="modelType">

</adapt>

</iterate>

</activeWhen>

</handler>



Context:



<extension point="org.eclipse.ui.contexts">

<context

id="myContext"

name="myContext"

parentId="org.eclipse.ui.contexts.window">

</context>





bindings:



<extension point="org.eclipse.ui.contexts">

<context

id="myContext"

name="myContext"

parentId="org.eclipse.ui.contexts.window">

</context>
Re: using shortcuts wile in text widgets run Eclipse command instead of text behavior [message #332533 is a reply to message #332522] Mon, 27 October 2008 14:20 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If I understand you correctly, you would need to have your handler
delegate the appropriate behaviour. For example,
org.eclipse.ui.actions.TextActionHandler (used for RetargetActions
though, not commands) provides a "model" behaviour and then allows text
controls to be added so that if they're in focus, you get the text copy
but if they're not in focus you get the model copy (for your tree, for
example).

You can use the IFocusService in a similar way for commands/handlers by
setting specific text controls to the default cut/copy/paste behaviour.
See the javadoc for IFocusService.

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/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:Declaration for the UFacekit Project
Next Topic:image decorator problem on table viewer .
Goto Forum:
  


Current Time: Fri Apr 26 10:37:21 GMT 2024

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

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

Back to the top