capint
2/28/2017 - 2:13 PM

Eclipse >> Common problems

  1. Editor loses focus, clicking on it doesn't regain focus
Problem: Editor loses focus, clicking on it doesn't regain focus.

=======================================================
Solution found at https://www.eclipse.org/forums/index.php/t/202763/

ViewPart opens Editor via some command.

In some cases our Editor's setFocus method tried to delegate focus to a SWT control which was disabled thus not taking focus (false returned).
Editor ignored that return value resulting in following state:
- Editor has focus but no control within has focus
- ViewPart had lost focus
(Probably SWT's and WorkbenchPart's focus are now out-of-sync)

Now clicking back into ViewPart doesn't give focus back to Viewpart, setFocus is not called by framework.

Remedy: Always assure that you delegate focus to a control that takes it (returns true).