Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to change KeyBindingService Scopes dynamically?
How to change KeyBindingService Scopes dynamically? [message #253632] Thu, 17 June 2004 10:12 Go to next message
Eclipse UserFriend
The problem is, I cannot dynamically change KeyBindingService scopes in a
MultiPageEditorPart.
It is OK when I set scopes in method "createPages()" of MultiPageEditorPart:
class MyEditor extends MultiPageEditorPart
implements IEditingDomainProvider, ISelectionProvider, IMenuListener {
...
public void createPages()
{
...
getSite().getKeyBindingServices().setScopes(new String[]
{"MyScope"});
...
}
...
}
But I want to change scopes when a Text is focused:
...
Text myText = new Text(composite, SWT.BORDER);
myText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
getSite().getKeyBindingServices().setScopes(new String[]
{"MyScope2"});
}
});
...
Setting the scope in the event handler takes no effect, until I switch to
another application window and switch back. What should I do to make the new
scope take effect? What happened when I switch to another window and switch
back?
Thanks a lot!!!
Re: How to change KeyBindingService Scopes dynamically? [message #253844 is a reply to message #253632] Fri, 18 June 2004 08:25 Go to previous message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Hank wrote:
> another application window and switch back. What should I do to make the
> new scope take effect? What happened when I switch to another window and
> switch back?

First off, this could probably be considered a bug. I'd need to do some
more research about the functionality promised by setScopes, but I would
hope that it was intended to work outside of page creation.

If you are using 3.0, then I would recommend using the following API
instead.

   Text myText = new Text(composite, SWT.BORDER);
EnabledSubmission submission = new
EnabledSubmission(null,text.getShell(),getSite(),"MyScope2");
IWorkbenchContextSupport contextSupport =
getSite().getWorkbenchWindow().getWorkbench().getContextSupp ort();
   myText.addFocusListener(new FocusListener() {
          public void focusGained(FocusEvent e)  {
              contextSupport.addEnabledSubmiss ion(submission);
          }
          public void focusLost(FocusEvent e)  {
              contextSupport.removeEnabledSubm ission(submission);
          }
   });


You must ensure that the submission is removed. If the focus lost event
isn't sent for some reason, then you will need to handle this case.
Otherwise, your context will remain active (as long as the site/shell
remain active) and you will leak memory.




d.
Previous Topic:workspace in use after shutdown
Next Topic:problem opening my perspective
Goto Forum:
  


Current Time: Mon Jul 14 15:04:36 EDT 2025

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

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

Back to the top