Focus problem with ViewPart and Editor [message #647919] |
Mon, 10 January 2011 08:20  |
Eclipse User |
|
|
|
Hi,
we encountered the following focus issue / problem in a RCP application (3.6):
We have a ViewPart with command handlers in Toolbar and ContextMenu that work perfectly at the beginning when this ViewPart has focus.
E.g. the command 'Edit' opens an Editor for a given selected item. Thereafter Editor has got the Focus.
Now i click back into ViewPart to do some other action. But now Focus (imho erratically) stays in Editor and won't switch to ViewPart, thus all command (handlers) not shown or active.
Only clicking on 'Tab' on top will give focus to this ViewPart but no clicks on content (e.g. list, tree, ..) will do so.
This occurs frequently but not always!
Anybody having the same problem or does anybody know how to solve this?
Thank you for your help,
chris
|
|
|
|
|
|
|
|
|
Re: Focus problem with ViewPart and Editor [message #648505 is a reply to message #648481] |
Thu, 13 January 2011 04:59  |
Eclipse User |
|
|
|
Hi all,
I think i know the reason for that behavior now:
Remember: 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).
If that isn't possible (all controls disabled) I don't have an idea what to do.
Maybe it's also possible from Eclipse's side to call ViewParts setFocus method in this special case?!
Best regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.04451 seconds