I'm having trouble getting a DrawingArea to have focus. I've set up all of the properties that I could find related to focus:
drawingArea.addEvents(GdkEventMask.ALL_EVENTS_MASK);
drawingArea.setCanFocus(true);
drawingArea.setFocusOnClick(true);
drawingArea.setReceivesDefault(true);
drawingArea.grabFocus();
Indeed, when the window opens the DrawingArea has focus, which I can see because the drawing handler checks the focus with hasFocus
and conditionally draws a line. But once I click some other control that captures focus (e.g. a TreeView) the focus never returns to the DrawingArea.
I thought that the DrawingArea might be rejecting the focus, so I tried adding handlers for addOnFocus
and addOnFocusIn
that returned true to prevent any other further event handling, but that didn't work either.
Any ideas?