From 8631fa2cad939c6d1cbcbe5148e210a0244f09eb Mon Sep 17 00:00:00 2001 From: Eric Prud'hommeaux Date: Mon, 21 Sep 2020 07:34:33 +0200 Subject: [PATCH 1/2] Add demo for promise-based context menu in text input --- documentation/demo/menu-promise.md | 109 +++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 documentation/demo/menu-promise.md diff --git a/documentation/demo/menu-promise.md b/documentation/demo/menu-promise.md new file mode 100644 index 00000000..8c5abc7f --- /dev/null +++ b/documentation/demo/menu-promise.md @@ -0,0 +1,109 @@ +--- +currentMenu: menu-promise +--- + +# Demo: Submenu through promise (asynchronous) + + + + + +- [Example code](#example-code) +- [Example HTML](#example-html) + + + +

right-clickable context menus

+ + +## Example code + + + +## Example HTML + From 59fec3a2d14373ca207549e490a38ac574f719f5 Mon Sep 17 00:00:00 2001 From: Eric Prud'hommeaux Date: Mon, 21 Sep 2020 07:54:58 +0200 Subject: [PATCH 2/2] Remove mouseup handler in demo/menu-promise --- documentation/demo/menu-promise.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/documentation/demo/menu-promise.md b/documentation/demo/menu-promise.md index 8c5abc7f..2dd2aa8a 100644 --- a/documentation/demo/menu-promise.md +++ b/documentation/demo/menu-promise.md @@ -58,17 +58,9 @@ currentMenu: menu-promise // right-click handler enables mouseup handler function rightClickHandler (e) { - e.preventDefault(); - const $this = $(this) - $this.on('mouseup', mouseUpHandler); - $this.off('contextmenu', rightClickHandler) - } - - // on mouseup, wait for the menu items and paint a context menu - function mouseUpHandler (e) { e.preventDefault(); const $this = $(this); - $this.off('mouseup', mouseUpHandler); + $this.off('contextmenu', rightClickHandler); // when the items are ready, buildMenuItemsPromise().then(items => { @@ -89,7 +81,6 @@ currentMenu: menu-promise $this.on('contextmenu', rightClickHandler) }); - return false } // callback insert letters over the selection