Commit 6cf65f62 authored by Oleg Korshul's avatar Oleg Korshul

1) Cmd + C/X/V on macOS Sierra

2) Copy/Paste by buttons on macOS Sierra (desktop)
parent 2bceb7b7
...@@ -456,7 +456,7 @@ var editor; ...@@ -456,7 +456,7 @@ var editor;
spreadsheet_api.prototype.asc_Copy = function() { spreadsheet_api.prototype.asc_Copy = function() {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Copy"](); window["asc_desktop_copypaste"](this, "Copy");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Copy(); return AscCommon.g_clipboardBase.Button_Copy();
...@@ -465,7 +465,7 @@ var editor; ...@@ -465,7 +465,7 @@ var editor;
spreadsheet_api.prototype.asc_Paste = function() { spreadsheet_api.prototype.asc_Paste = function() {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Paste"](); window["asc_desktop_copypaste"](this, "Paste");
return true; return true;
} }
if (!AscCommon.g_clipboardBase.IsWorking()) { if (!AscCommon.g_clipboardBase.IsWorking()) {
...@@ -477,7 +477,7 @@ var editor; ...@@ -477,7 +477,7 @@ var editor;
spreadsheet_api.prototype.asc_Cut = function() { spreadsheet_api.prototype.asc_Cut = function() {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Cut"](); window["asc_desktop_copypaste"](this, "Cut");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Cut(); return AscCommon.g_clipboardBase.Button_Cut();
......
...@@ -233,6 +233,17 @@ window["asc_initAdvancedOptions"] = function(_code) ...@@ -233,6 +233,17 @@ window["asc_initAdvancedOptions"] = function(_code)
_editor._onNeedParams(undefined, (_code == 90 || _code == 91) ? true : undefined); _editor._onNeedParams(undefined, (_code == 90 || _code == 91) ? true : undefined);
}; };
// copy/paste focus error!!!
window["asc_desktop_copypaste"] = function(_api, _method)
{
var bIsFocus = _api.asc_IsFocus();
if (!bIsFocus)
_api.asc_enableKeyEvents(true);
window["AscDesktopEditor"][_method]();
if (!bIsFocus)
_api.asc_enableKeyEvents(false);
}
// меняем среду // меняем среду
//AscBrowser.isSafari = false; //AscBrowser.isSafari = false;
//AscBrowser.isSafariMacOs = false; //AscBrowser.isSafariMacOs = false;
......
...@@ -160,6 +160,8 @@ ...@@ -160,6 +160,8 @@
// еще один режим для ie & edge // еще один режим для ie & edge
this.IsUseInputEventOnlyWithCtx = (AscCommon.AscBrowser.isIE) ? true : false; this.IsUseInputEventOnlyWithCtx = (AscCommon.AscBrowser.isIE) ? true : false;
this.IsInitialInputContext = false; this.IsInitialInputContext = false;
this.IsDisableKeyPress = false;
} }
CTextInput.prototype = CTextInput.prototype =
...@@ -234,14 +236,32 @@ ...@@ -234,14 +236,32 @@
var oThis = this; var oThis = this;
this.HtmlArea["onkeydown"] = function(e) this.HtmlArea["onkeydown"] = function(e)
{ {
if (AscCommon.AscBrowser.isSafariMacOs)
{
var cmdButton = (e.ctrlKey || e.metaKey) ? true : false;
var buttonCode = ((e.keyCode == 67) || (e.keyCode == 88) || (e.keyCode == 86));
if (cmdButton && buttonCode)
oThis.IsDisableKeyPress = true;
else
oThis.IsDisableKeyPress = false;
}
return oThis.onKeyDown(e); return oThis.onKeyDown(e);
}; };
this.HtmlArea["onkeypress"] = function(e) this.HtmlArea["onkeypress"] = function(e)
{ {
if (oThis.IsDisableKeyPress == true)
{
// macOS Sierra send keypress before copy event
oThis.IsDisableKeyPress = false;
var cmdButton = (e.ctrlKey || e.metaKey) ? true : false;
if (cmdButton)
return;
}
return oThis.onKeyPress(e); return oThis.onKeyPress(e);
}; };
this.HtmlArea["onkeyup"] = function(e) this.HtmlArea["onkeyup"] = function(e)
{ {
oThis.IsDisableKeyPress = false;
return oThis.onKeyUp(e); return oThis.onKeyUp(e);
}; };
...@@ -1529,6 +1549,13 @@ ...@@ -1529,6 +1549,13 @@
this.InterfaceEnableKeyEvents = value; this.InterfaceEnableKeyEvents = value;
if (true == this.InterfaceEnableKeyEvents) if (true == this.InterfaceEnableKeyEvents)
{ {
if (document.activeElement)
{
var _id = document.activeElement.id;
if (_id == "area_id" || _id == "plugin_iframe")
return;
}
this.HtmlArea.focus(); this.HtmlArea.focus();
} }
}, },
......
...@@ -1824,7 +1824,7 @@ background-repeat: no-repeat;\ ...@@ -1824,7 +1824,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Copy"](); window["asc_desktop_copypaste"](this, "Copy");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Copy(); return AscCommon.g_clipboardBase.Button_Copy();
...@@ -1837,7 +1837,7 @@ background-repeat: no-repeat;\ ...@@ -1837,7 +1837,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Cut"](); window["asc_desktop_copypaste"](this, "Cut");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Cut(); return AscCommon.g_clipboardBase.Button_Cut();
...@@ -1846,7 +1846,7 @@ background-repeat: no-repeat;\ ...@@ -1846,7 +1846,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Paste"](); window["asc_desktop_copypaste"](this, "Paste");
return true; return true;
} }
......
...@@ -1853,7 +1853,7 @@ background-repeat: no-repeat;\ ...@@ -1853,7 +1853,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Copy"](); window["asc_desktop_copypaste"](this, "Copy");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Copy(); return AscCommon.g_clipboardBase.Button_Copy();
...@@ -1866,7 +1866,7 @@ background-repeat: no-repeat;\ ...@@ -1866,7 +1866,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Cut"](); window["asc_desktop_copypaste"](this, "Cut");
return true; return true;
} }
return AscCommon.g_clipboardBase.Button_Cut(); return AscCommon.g_clipboardBase.Button_Cut();
...@@ -1875,7 +1875,7 @@ background-repeat: no-repeat;\ ...@@ -1875,7 +1875,7 @@ background-repeat: no-repeat;\
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["Paste"](); window["asc_desktop_copypaste"](this, "Paste");
return true; return true;
} }
if (!this.WordControl.m_oLogicDocument) if (!this.WordControl.m_oLogicDocument)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment