Open io7m opened 8 years ago
It may be worth strengthening the semanics of component selection a bit more. At least, it'd mean that the fix to this is a single line change.
Essentially, what happens now is that when the cursor overlaps a component, each child of that component is checked in turn to see if the cursor overlaps any of them. The idea being that the most specific child components (ie. the leaves of the tree) should receive events first and then pass them back up the tree if they don't handle them. Right now, for a given component c
, the algorithm checks each direct child of c
, stopping at the first child that matches. The current window implementation attaches components to the root window in this order: frame
, titlebar
, contentPane
. This means that if the frame overlaps something, the frame wins.
WindowRoot(final String in_text)
{
this.setWindow(Optional.of(SyWindowAbstract.this));
this.setSelectable(false);
this.titlebar = new Titlebar(in_text);
this.frame = new Frame();
this.content_pane = new ContentPane();
final JOTreeNodeType<SyComponentType> node = this.node();
node.childAdd(this.frame.node());
node.childAdd(this.titlebar.node());
node.childAdd(this.content_pane.node());
}
The "fix" (read: workaround that depends on undeclared semantics) is to add the titlebar first.
It feels like the most recently added component should take priority. It has nicer properties such as being able to make a component take priority by simply detaching and re-adding it. If the first component takes priority, then either an extra API needs to be added (via jorchard
) to add a component as the first child of a tree node, or all components must be removed and re-added to change the priority.
Unfortunately, this means that the way jorchard
presents child nodes needs to be updated...
With
PLACEMENT_TOP_OVERLAP_FRAME
, any region of the frame underneath the titlebar will receive mouse events instead of the titlebar. This is in keeping with the component model, but is unfortunate!