IDEMPIERE-4702 Messagebox enhancement: Esc key closes Dialog with cancel (#586)

action

Co-authored-by: Andreas <sumerauer@kanzlei-wmv.de>
This commit is contained in:
Andreas Sumerauer 2021-02-16 01:41:41 +01:00 committed by GitHub
parent ff88459dc9
commit 6acc8e235d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 5 deletions

View File

@ -38,6 +38,7 @@ import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Image;
import org.zkoss.zul.Vbox;
@ -47,6 +48,7 @@ import org.zkoss.zul.Vbox;
*
* @author Niraj Sohun
* @date Jul 31, 2007
* @contributor Andreas Sumerauer IDEMPIERE-4702
*/
public class Messagebox extends Window implements EventListener<Event>
@ -107,7 +109,7 @@ public class Messagebox extends Window implements EventListener<Event>
public static final String QUESTION = "~./zul/img/msgbox/question-btn.png";
/** A symbol consisting of an exclamation point in a triangle with a yellow background. */
public static final String EXCLAMATION = "~./zul/img/msgbox/warning-btn.png";
public static final String EXCLAMATION = "~./zul/img/msgbox/warning-btn.png";
/** A symbol of a lowercase letter i in a circle. */
public static final String INFORMATION = "~./zul/img/msgbox/info-btn.png";
@ -354,6 +356,15 @@ public class Messagebox extends Window implements EventListener<Event>
return msg.show(message, title, buttons, icon, editor, callback, modal);
}
// Andreas Sumerauer IDEMPIERE 4702
@Listen("onCancel")
public void onCancel() throws Exception
{
returnValue = CANCEL;
close();
}
public void onEvent(Event event) throws Exception
{
if (event == null)
@ -387,7 +398,10 @@ public class Messagebox extends Window implements EventListener<Event>
{
returnValue = IGNORE;
}
close();
}
private void close() {
try {
this.detach();
} catch (NullPointerException npe) {