IDEMPIERE-3232 Useless to set focus on a readonly field

Improve next focus on capturing when selecting a value from a list or an info window
This commit is contained in:
Carlos Ruiz 2020-02-12 23:54:01 +01:00
parent ce8dc4aedd
commit 46c60f34b8
5 changed files with 28 additions and 15 deletions

View File

@ -1880,7 +1880,11 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
continue;
}
if (found) {
if (editor.isVisible() && editor.isReadWrite()) {
if (editor.isVisible() && editor.isReadWrite()
// note, no auto focus on next button - if interested in
// focusing next button must implement to check if the button
// is just showin in toolbar, just focus on window fields must be auto focused
&& ! (editor instanceof WButtonEditor)) {
focusToEditor(editor, false);
break;
}

View File

@ -26,6 +26,7 @@ import java.util.Properties;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.IFieldEditorContainer;
import org.adempiere.webui.component.Bandbox;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Datebox;
@ -813,6 +814,18 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
return null;
}
protected void focusNext() {
Component comp = getComponent();
Component parent = comp.getParent();
while (parent != null) {
if (parent instanceof IFieldEditorContainer) {
((IFieldEditorContainer) parent).focusToNextEditor(this);
break;
}
parent = parent.getParent();
}
}
protected Evaluatee getStyleEvaluatee() {
return new EvaluateeWrapper(this, gridField, tableEditor);
}

View File

@ -278,6 +278,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
super.fireValueChange(changeEvent);
oldValue = newValue;
}
if (newValue != null)
focusNext();
}
else if (Events.ON_BLUR.equalsIgnoreCase(event.getName()))
{

View File

@ -29,7 +29,6 @@ import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.ValuePreference;
import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.adwindow.ADWindowContent;
import org.adempiere.webui.adwindow.IFieldEditorContainer;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Searchbox;
import org.adempiere.webui.event.ContextMenuEvent;
@ -390,17 +389,8 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
log.fine(getColumnName() + " - Unique ID=" + id);
actionCombo(Integer.valueOf(id)); // data binding
Searchbox comp = getComponent();
Component parent = comp.getParent();
while (parent != null) {
if (parent instanceof IFieldEditorContainer) {
((IFieldEditorContainer) parent).focusToNextEditor(this);
break;
}
parent = parent.getParent();
}
focusNext();
//safety check: if focus is going no where, focus back to self
String uid = getComponent().getTextbox().getUuid();
String script = "setTimeout(function(){try{var e = zk.Widget.$('#" + uid +
@ -599,6 +589,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
actionCombo (result);
else
actionCombo (result[0]);
focusNext();
}
else if (cancelled)
{
@ -612,13 +603,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
}else{
getComponent().setText("");
actionCombo(null);
}
}
getComponent().getTextbox().focus();
}
else
{
if (log.isLoggable(Level.CONFIG)) log.config(getColumnName() + " - Result = null (not cancelled)");
getComponent().getTextbox().focus();
}
getComponent().getTextbox().focus();
}
});
ip.setId(ip.getTitle()+"_"+ip.getWindowNo());

View File

@ -507,6 +507,8 @@ ContextMenuListener, IZoomableEditor
gridField.setLookupEditorSettingValue(false);
}
}
if (newValue != null)
focusNext();
} finally {
onselecting = false;
}