Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [GEF5 MVC] Change focus/selection by TAB
[GEF5 MVC] Change focus/selection by TAB [message #1820869] Thu, 30 January 2020 20:54 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 169
Registered: July 2009
Senior Member
Hi,

I try to get an example working, changing the focus and selection of next node (content part) via Tab.

I see in the MindMap example that it is not implemented as TAB leads to this exception:
java.lang.NullPointerException
	at org.eclipse.gef.mvc.fx.gestures.DefaultHandlerResolver.resolve(DefaultHandlerResolver.java:65)


In my trial, I have a viewer with 3 parts, with selection feedback.
To make focus change by TAB work, i need to configure for my content part adapters FocusTraversalPolicy+FocusBehavior+TraverseFocusOnTypeHandler

Doing this, having one part selected by click, then TAB, the selection feedback is not changing. However, via debugger i see the focus is changing.
To solve, i can listen on the focusProperty and set the part in the selection model.
visual.focusedProperty().addListener((obsv, ov, nv) -> {
	SelectionModel sm = getViewer().getAdapter(SelectionModel.class);
	if( !ov && nv ) {
		sm.setSelection(this);
		System.out.println("focused " + visual);
	}
	if( ov && !nv ) {
		sm.removeFromSelection(this);
		System.out.println("unfocused " + visual);
	}
});

Is there an existing mechanism that implements this?

When I TAB through, after last part, it selects the viewer. TAB again does not start with the first part.
Cyclic tabbing is supported with existing logic?

And finally
Backwards tabbing seems not be supported, so I need to implement my own version of TraverseFocusOnTypeHandler?

Frank
Re: [GEF5 MVC] Change focus/selection by TAB [message #1820870 is a reply to message #1820869] Thu, 30 January 2020 21:06 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 169
Registered: July 2009
Senior Member
... the backwards tabbing can be fixed in TraverseFocusOnTypeHandler#press to forward to initialPress.
The SHIFT-TAB, call intialPress with SHIFT only, then the press with SHIFT-TAB.

Re: [GEF5 MVC] Change focus/selection by TAB [message #1820920 is a reply to message #1820870] Fri, 31 January 2020 17:35 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 135
Registered: February 2016
Senior Member
See also the corresponding Bugzilla issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=559727
Re: [GEF5 MVC] Change focus/selection by TAB [message #1820934 is a reply to message #1820920] Sat, 01 February 2020 13:34 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 169
Registered: July 2009
Senior Member
Please do not overlook the first 2 questions.

[Updated on: Sat, 01 February 2020 13:34]

Report message to a moderator

Re: [GEF5 MVC] Change focus/selection by TAB [message #1822409 is a reply to message #1820934] Thu, 05 March 2020 18:30 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Frank,

apart from the tab traversal problems in the MVC logo example, this is how it should work:

There is a distinction between focus and selection, i.e. focus traversal does not necessarily be visible (e.g. if there is no focus feedback) and it is independent from selection.
FocusTraversalPolicy implements the focus traversal algorithm. The resulting focus change is executed via ChangeFocusOperation.
FocusModel stores the currently focused part.
SelectionModel stores the currently selected parts.
Feedback and Handles are generated for focus and selection via FocusBehavior, SelectionBehavior, and the corresponding factories and providers.

1) Changing selection when changing focus.
You should perform (model) changes via operations, so that they will be undoable. In this case, you want to change the actions taken when traversing focus. Therefore, the ideal entry point would be the FocusTraversalPolicy:
- SelectionFocusTraversalPolicy extends FocusTraversalPolicy
-- ensure that focus traversal will also change the selection (override createOperation(), getFocusChangeOperation(), traverse(), add getSelectionChangeOperation()).
- Exchange the binding in your module.

2) Cyclic tabbing should work. However, the "nothing is focused" (focus=null) case is part of the cycle. For details, take a look at FocusTraversalPolicy#traverse() etc.

3) Due to the SHIFT-bug, I believe you need to fix backwards tabbing by implementing your own (maybe subclassed) handler. The policy does provide means to traverse backwards.

I hope this makes sense. The tab traversal code is definitely not challenged enough.

Best regards,
Matthias
Previous Topic:how to complete "drag and drop"
Next Topic:SpaceTreeLayoutAlgorithm fails when node count is high
Goto Forum:
  


Current Time: Thu Dec 02 04:48:47 GMT 2021

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

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

Back to the top