Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ifigure focus(instant focusLost after focusGained)
ifigure focus [message #991211] Mon, 17 December 2012 19:12 Go to next message
michael jordan is currently offline michael jordan
Messages: 3
Registered: December 2012
Junior Member
i am currently writing an editor which displays a tree as nested boxes (tree root = outer box, children are contained within that box, etc)

my first figure is a FreeformLayer and then the hierarchy is created from nested "PlanFigure extends Figure" - so the freeformlayer contains 1 planfigure representing the root box (which then contains the hierarchy)

every box has
setRequestFocusEnabled(true);
		addMouseListener(new MouseListener.Stub() {
			@Override
			public void mousePressed(MouseEvent me) {
				requestFocus();
			}
		});
		addFocusListener(new FocusListener.Stub() {
			@Override
			public void focusGained(FocusEvent fe) {
				super.focusGained(fe);
				System.out.println(System.currentTimeMillis() + " : focus gained " + name);
			}

			@Override
			public void focusLost(FocusEvent fe) {
				super.focusLost(fe);
				System.out.println(System.currentTimeMillis() + " : " + name + " >> focus lost to " + fe.gainer);
			}
		});


when i click at any figure i immediately get the output like

1355771536094 : focus gained A
1355771536095 : A >> focus lost to null


my question: why do my figures immediately lose focus to nothing?
Re: ifigure focus [message #991217 is a reply to message #991211] Mon, 17 December 2012 19:57 Go to previous message
michael jordan is currently offline michael jordan
Messages: 3
Registered: December 2012
Junior Member
after some trial and error the answer is
		addMouseListener(new MouseListener.Stub() {
			@Override
			public void mousePressed(MouseEvent me) {
				requestFocus();
				me.consume();
			}
		});


apparently not consuming the event must lead to the event being further processed, finally arriving at the default behavior/assumption that nothing was clicked (since the event was not consumed) and thus the current figure loses focus; this is speculation on my part even though it seems reasonable
Previous Topic:Move parent when child is draged
Next Topic:Separating and Saving "View Information"
Goto Forum:
  


Current Time: Fri Oct 24 16:57:38 GMT 2014

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

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