Hi,
I have implemented a subclass of TableViewRowEditor which doesn't allow the
user to close the editor if the input is not valid (along the lines of
http://apache-pivot-users.399431.n3.nabble.com/TextInput-and-Validator-issues-tp2641141p2648160.html).
I have been attempting to do the same with a ListViewItemEditor and found what
looks like a bug. I didn't subclass the editor as it would require me to
override nearly every method, so I just copied the code into my own class.
The issue is that I can open the item for editing but can't stop the editor
from closing if the input is invalid. Pressing enter or escape is fine - the
editor remains open and focussed, but I'm not prevented from clicking anywhere
else with the mouse (editor still remains open, but not focussed).
Having a look at the code, I believe the issue is in the mouseDown method of
displayMouseHandler. When I changed the code there to mirror that of
TableViewRowEditor, the issue is resolved for me. It looks like the mouse
click is not consumed when it should be.
As an aside, there were 2 commits (revisions 1041913 and 1079009) which changed
this code in TableViewRowEditor to the current code. Looking briefly at
TreeViewNodeEditor leads me to suspect that it too would benefit from this fix
(although I haven't used it so can't confirm that).
So the fix that I did was to change this:
@Override
public boolean mouseDown(Container container, Mouse.Button button, int
x, int y) {
Display display = (Display)container;
Window window = (Window)display.getComponentAt(x, y);
if (window != ListViewItemEditor.this) {
endEdit(true);
}
return false;
}
To this:
@Override
public boolean mouseDown(Container container, Mouse.Button button, int
x, int y) {
Display display = (Display)container;
Window window = (Window)display.getComponentAt(x, y);
boolean consumed;
if (window != ListViewItemEditor.this
&& (window == null || !isOwner(window))) {
endEdit(true);
consumed = true;
} else {
consumed = false;
}
return consumed;
}
Regards,
David