mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +01:00
Add esc/enter support to cancel or accept popups.
This commit is contained in:
parent
31cec107b0
commit
57c928f195
@ -7,7 +7,10 @@ function initShapeDialog() {
|
||||
$("#btnShapePlus").on("onButtonHold",onShapePlus);
|
||||
$("#btnShapeMin").on("onButtonHold",onShapeMin);
|
||||
updateShapePreview();
|
||||
|
||||
shapePopup = new Popup($("#popupShape"), $("#popupMask"));
|
||||
shapePopup.setEscapeKeyHandler(onShapeCancel);
|
||||
shapePopup.setEnterKeyHandler(onShapeOk);
|
||||
}
|
||||
|
||||
function showShapeDialog() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
var keyboardShortcutsEnabled = true;
|
||||
var keyboardEscapeEnterEnabled = false;
|
||||
var wordBuffer = "";
|
||||
|
||||
var wordFuncs = {
|
||||
@ -14,6 +15,17 @@ function initKeyboard() {
|
||||
|
||||
$(document).keypress(function(event) {
|
||||
|
||||
if (keyboardEscapeEnterEnabled) {
|
||||
switch (event.keyCode) {
|
||||
case 13:
|
||||
$(document).trigger("onEnterKey");
|
||||
break;
|
||||
case 27:
|
||||
$(document).trigger("onEscapeKey");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!keyboardShortcutsEnabled) return;
|
||||
if (event.ctrlKey && event.altKey && ! event.metaKey) processWords(event);
|
||||
if (event.altKey || event.ctrlKey || event.metaKey) return; //ignore key presses with modifier keys except shift
|
||||
|
30
js/Popup.js
30
js/Popup.js
@ -1,20 +1,34 @@
|
||||
function Popup(element,mask) {
|
||||
|
||||
function Popup(element, mask) {
|
||||
var self = this;
|
||||
var escapeKeyHandler = null;
|
||||
var enterKeyHandler = null;
|
||||
|
||||
this.open = function(complete,disableMaskClick) {
|
||||
this.open = function(complete, disableMaskClick) {
|
||||
mask.fadeIn(POPUP_SHOW_DURATION);
|
||||
element.fadeIn(POPUP_SHOW_DURATION, complete);
|
||||
keyboardShortcutsEnabled=false;
|
||||
document.body.removeEventListener('touchmove',prevent,false);
|
||||
|
||||
keyboardShortcutsEnabled = false;
|
||||
keyboardEscapeEnterEnabled = true;
|
||||
|
||||
document.body.removeEventListener('touchmove', prevent, false);
|
||||
mask.bind("onButtonClick", function() { self.close() });
|
||||
if (escapeKeyHandler) $(document).bind("onEscapeKey", escapeKeyHandler);
|
||||
if (enterKeyHandler) $(document).bind("onEnterKey", enterKeyHandler);
|
||||
}
|
||||
|
||||
this.close = function(complete) {
|
||||
mask.fadeOut(POPUP_SHOW_DURATION);
|
||||
element.fadeOut(POPUP_SHOW_DURATION,complete);
|
||||
element.fadeOut(POPUP_SHOW_DURATION, complete);
|
||||
|
||||
keyboardShortcutsEnabled=true;
|
||||
document.body.addEventListener('touchmove',prevent,false);
|
||||
keyboardShortcutsEnabled = true;
|
||||
keyboardEscapeEnterEnabled = false;
|
||||
|
||||
document.body.addEventListener('touchmove', prevent, false);
|
||||
mask.unbind("onButtonClick");
|
||||
if (escapeKeyHandler) $(document).unbind("onEscapeKey");
|
||||
if (enterKeyHandler) $(document).unbind("onEnterKey");
|
||||
}
|
||||
|
||||
this.setEscapeKeyHandler = function(hnd) { escapeKeyHandler = hnd; }
|
||||
this.setEnterKeyHandler = function(hnd) { enterKeyHandler = hnd; }
|
||||
}
|
@ -1,11 +1,14 @@
|
||||
var wordArtPopup;
|
||||
|
||||
function initWordArt() {
|
||||
$("body").append('<div id="svgfont" style="display:none"></div>');
|
||||
$("#svgfont").load("img/font.svg?");
|
||||
$("body").append('<div id="svgfont" style="display:none"></div>');
|
||||
$("#svgfont").load("img/font.svg?");
|
||||
$("#btnWordArtOk").on("onButtonClick",onWordArtOk);
|
||||
$("#btnWordArtCancel").on("onButtonClick",onWordArtCancel);
|
||||
|
||||
wordArtPopup = new Popup($("#popupWordArt"),$("#popupMask"));
|
||||
wordArtPopup.setEscapeKeyHandler(onWordArtCancel);
|
||||
wordArtPopup.setEnterKeyHandler(onWordArtOk);
|
||||
}
|
||||
|
||||
function showWordArtDialog() {
|
||||
|
Loading…
Reference in New Issue
Block a user