Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 439860

Summary: Add support for handling keyboard focus
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF MVCAssignee: Matthias Wienand <matthias.wienand>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2014-07-18 02:26:49 EDT
We need to add support for keyboard focus. That is, an IFocusModel is needed for each viewer, which comprises the focus part. We also need a mechanism to keep track of which viewer actually has focus. The focus part should indicate via feedback whether the viewer has focus or not. In case the user selects via the mouse, the selected part should also become the focus part (and the viewer should get focus). As such, focus and  selection feedback are orthogonal to each other and a part needs to be able to indicate both (in GEF 3.x MVC, there is no focus indication when the selected part is also the focus part, which is bad, because the user does not recognize whether the viewer has focus).
Comment 1 Matthias Wienand CLA 2014-07-18 11:48:31 EDT
I added an FXFocusTool to keep track of the viewer focus and extended the FXSelectOnClickPolicy to also change the IFocusModel, i.e. keep track of the focused part (and thus renamed it to FXFocusAndSelectOnClickPolicy).

To synchronize the IFocusModel and the JavaFX "focusOwner" an FXFocusBehavior requests focus for its host visual ("focusOwner") when its host is focused (IFocusModel) and the FXClickDragTool consumes mouse press events to prevent default JavaFX event handlers from changing the "focusOwner".

The focus information is evaluated when generating selection feedback. Focus information is encoded in the feedback effect color. Selection information is encoded in the feedback stroke color:

  selected (primary) and focused: black stroke, blue effect
  selected (secondary) and focused: grey stroke, blue effect
  selected (primary) and not focused: black stroke, grey effect
  selected (secondary) and not focused: grey stroke, grey effect

The code is published on the master branch. Therefore, I am changing the status to RESOLVED, FIXED.