fix hotkey support

pull/125/merge
nightwing 2017-03-22 23:01:35 +04:00
rodzic 930590ab92
commit b99bcddf65
15 zmienionych plików z 115 dodań i 343 usunięć

Wyświetl plik

@ -240,7 +240,7 @@ define(function(require, exports, module) {
// detected from document value // detected from document value
["newLineMode", "unix", STRING, "newlinemode", 1], ["newLineMode", "unix", STRING, "newlinemode", 1],
// Per document // Per document
["tabSize", "4", NUMBER, "tabsize", 1], ["tabSize", 4, NUMBER, "tabsize", 1],
["useSoftTabs", true, BOOL, "softtabs", 1], ["useSoftTabs", true, BOOL, "softtabs", 1],
["guessTabSize", true, BOOL, "guesstabsize", 1], ["guessTabSize", true, BOOL, "guesstabsize", 1],
["useWrapMode", false, BOOL, "wrapmode"], ["useWrapMode", false, BOOL, "wrapmode"],

Wyświetl plik

@ -364,7 +364,7 @@ define(function(require, module, exports) {
new ui.item({ new ui.item({
caption: "New File", caption: "New File",
// TODO // TODO
// hotkey: "{commands.commandManager.newfile}", hotkey: "commands.newfile",
onclick: function(e) { onclick: function(e) {
e.pane = this.parentNode.pane; e.pane = this.parentNode.pane;
plusNewFile(e, true); plusNewFile(e, true);

Wyświetl plik

@ -178,10 +178,7 @@ define(function(require, exports, module) {
thingy.onclick = function() { togglePopup(def); }; thingy.onclick = function() { togglePopup(def); };
def.body = def.body.replace(/\$\{key:([a-zA-Z]+)\}/g, function(match, name) { def.body = def.body.replace(/\$\{key:([a-zA-Z]+)\}/g, function(match, name) {
var key = commands.getHotkey(name); return commands.getPrettyHotkey(name);
if (commands.platform == "mac")
key = apf.hotkeys.toMacNotation(key);
return key;
}); });
def.el = el; def.el = el;

Wyświetl plik

@ -25,9 +25,7 @@ define(function(require, exports, module) {
loaded = true; loaded = true;
commands.on("update", function() { commands.on("update", function() {
var key = commands.getHotkey("quickfix"); var key = commands.getPrettyHotkey("quickfix");
if (commands.platform == "mac")
key = apf.hotkeys.toMacNotation(key);
language.getWorker(function(err, result) { language.getWorker(function(err, result) {
if (err) return console.error(err); if (err) return console.error(err);

Wyświetl plik

@ -144,18 +144,12 @@ define(function(require, module, exports) {
options.extra.apply(this, arguments); options.extra.apply(this, arguments);
} }
}, plugin); }, plugin);
if (mnuItem)
// TODO mnuItem.setAttribute("hotkey", "commands." + options.name);
// mnuItem.setAttribute("hotkey", if (button) {
// "{commands.commandManager." + options.name + "}"); button.setAttribute("hotkey", "commands." + options.name);
button.setAttribute("tooltip", options.name);
if (button && button.setAttribute) {
var key = commands.getPrettyHotkey(options.name);
button.setAttribute("tooltip", options.name
+ (key ? " (" + key + ")" : ""));
} }
return command; return command;
} }
@ -211,13 +205,16 @@ define(function(require, module, exports) {
var container = area.draw(); var container = area.draw();
if (!button) { if (!button) {
var hotkey = mnuItem && mnuItem.getAttribute("hotkey") || "";
// Insert button // Insert button
button = new ui.button({ button = new ui.button({
skinset: "panels", skinset: "panels",
state: true, state: true,
caption: caption, caption: caption,
auto: false, auto: false,
"class": buttonCSSClass || "", class: buttonCSSClass || "",
hotkey: hotkey,
tooltip: hotkey.slice(9),
onmousedown: function(e) { onmousedown: function(e) {
if (e.htmlEvent && e.htmlEvent.button) return; if (e.htmlEvent && e.htmlEvent.button) return;
panels.areas[where].toggle(plugin.name, autohide, true); panels.areas[where].toggle(plugin.name, autohide, true);

Wyświetl plik

@ -90,7 +90,7 @@ define(function(require, exports, module) {
menus.addItemToMenu(menu, menus.addItemToMenu(menu,
new ui.item({ new ui.item({
caption: "Open Preferences", caption: "Open Preferences",
// hotkey: "{commands.commandManager.openpreferences}", hotkey: "commands.openpreferences",
onclick: function(e) { onclick: function(e) {
if (focusOpenPrefs()) if (focusOpenPrefs())
return; return;

Wyświetl plik

@ -230,9 +230,7 @@ define(function(require, exports, module) {
menu = new Menu({}, handle); menu = new Menu({}, handle);
// Preferences // Preferences
var key = commands.getHotkey("reloadpreview"); var key = commands.getPrettyHotkey("reloadpreview");
if (commands.platform == "mac")
key = apf.hotkeys.toMacNotation(key);
prefs.add({ prefs.add({
"Project": { "Project": {

Wyświetl plik

@ -360,7 +360,7 @@ define(function(require, module, exports) {
menus.addItemToMenu(tabs.getElement("mnuEditors"), menus.addItemToMenu(tabs.getElement("mnuEditors"),
new ui.item({ new ui.item({
caption: "New Run Configuration", caption: "New Run Configuration",
// hotkey: "{commands.commandManager.showoutput}", hotkey: "commands.showoutput",
onclick: function(e) { onclick: function(e) {
commands.exec("showoutput", null, { commands.exec("showoutput", null, {
pane: this.parentNode.pane pane: this.parentNode.pane

Wyświetl plik

@ -174,7 +174,7 @@ define(function(require, exports, module) {
var ctxItem = menus.addItemToMenu(menu, var ctxItem = menus.addItemToMenu(menu,
new ui.item({ new ui.item({
caption: "New Terminal", caption: "New Terminal",
// hotkey: "{commands.commandManager.openterminal}", hotkey: "commands.openterminal",
onclick: function(e) { onclick: function(e) {
tabs.open({ tabs.open({
active: true, active: true,

Wyświetl plik

@ -26,11 +26,6 @@ define(function(require, exports, module) {
var debug = location.href.indexOf('menus=1') > -1; var debug = location.href.indexOf('menus=1') > -1;
var headings = {}; var headings = {};
if (!Form.proxy) {
Form.proxy = new apf.Class().$init();
apf.nameserver.register("all", "Form", Form);
}
var loaded; var loaded;
function load() { function load() {
@ -155,19 +150,6 @@ define(function(require, exports, module) {
name = name.replace(/@(.*)/, "$1Attribute"); name = name.replace(/@(.*)/, "$1Attribute");
return name; return name;
} }
function createBind(path) {
var name = getName(path);
Form.proxy.setProperty(name, settings.get(path));
Form.proxy.on("prop." + name, function(e) {
settings.set(path, e.value);
});
settings.on(path, function(value) {
if (Form.proxy[name] != value)
Form.proxy.setProperty(name, value);
}, plugin);
return name //"{Form.proxy." + name + "}";
}
function createItem(heading, name, options, foreign) { function createItem(heading, name, options, foreign) {
if (!foreign) foreign = plugin; if (!foreign) foreign = plugin;
@ -187,11 +169,14 @@ define(function(require, exports, module) {
new ui.label({ width: width, maxwidth: maxwidth, caption: name + ":" }), new ui.label({ width: width, maxwidth: maxwidth, caption: name + ":" }),
new ui.checkbox({ new ui.checkbox({
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
values: options.values, values: options.values,
skin: "cboffline", skin: "cboffline",
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value }); options.onchange({ value: e.value });
} }
@ -199,15 +184,11 @@ define(function(require, exports, module) {
]; ];
break; break;
case "dropdown": case "dropdown":
var model = options.model || new ui.model();
var data = options.items;
if (data) model.load(data);
var dd; var dd;
childNodes = [ childNodes = [
new ui.label({ width: width, maxwidth: maxwidth, caption: name + ":" }), new ui.label({ width: width, maxwidth: maxwidth, caption: name + ":" }),
dd = new ui.dropdown({ dd = new ui.dropdown({
model: model, items: options.items,
width: options.width || widths.dropdown, width: options.width || widths.dropdown,
skin: "black_dropdown", skin: "black_dropdown",
margin: "-1 0 0 0", margin: "-1 0 0 0",
@ -239,12 +220,14 @@ define(function(require, exports, module) {
new ui.spinner({ new ui.spinner({
width: options.width || widths.spinner, width: options.width || widths.spinner,
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
min: options.min || 0, min: options.min || 0,
max: options.max || 10, max: options.max || 10,
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1, realtime: typeof options.realtime !== "undefined" ? options.realtime : 1,
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value }); options.onchange({ value: e.value });
}, },
@ -255,12 +238,14 @@ define(function(require, exports, module) {
childNodes = [ childNodes = [
new ui.checkbox({ new ui.checkbox({
value: options.checkboxPath value: options.checkboxPath
? createBind(options.checkboxPath) ? settings.get(options.checkboxPath)
: (options.defaultCheckboxValue || ""), : (options.defaultCheckboxValue || ""),
width: width, maxwidth: maxwidth, width: width, maxwidth: maxwidth,
label: name + ":", label: name + ":",
skin: "checkbox_black", skin: "checkbox_black",
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value, type: "checkbox" }); options.onchange({ value: e.value, type: "checkbox" });
}, },
@ -268,12 +253,14 @@ define(function(require, exports, module) {
new ui.spinner({ new ui.spinner({
width: options.width || widths["checked-spinner"], width: options.width || widths["checked-spinner"],
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
min: options.min || 0, min: options.min || 0,
max: options.max || 10, max: options.max || 10,
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1, realtime: typeof options.realtime !== "undefined" ? options.realtime : 1,
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value, type: "spinner" }); options.onchange({ value: e.value, type: "spinner" });
}, },
@ -284,12 +271,14 @@ define(function(require, exports, module) {
childNodes = [ childNodes = [
new ui.checkbox({ new ui.checkbox({
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
width: options.width || widths["checked-single"], width: options.width || widths["checked-single"],
label: name, label: name,
skin: "checkbox_black", skin: "checkbox_black",
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value }); options.onchange({ value: e.value });
} }
@ -305,10 +294,12 @@ define(function(require, exports, module) {
"initial-message": options.message || "", "initial-message": options.message || "",
width: options.width || widths.textbox, width: options.width || widths.textbox,
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1, realtime: typeof options.realtime !== "undefined" ? options.realtime : 1,
onafterchange: function(e) { onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange) if (options.onchange)
options.onchange({ value: e.value }); options.onchange({ value: e.value });
}, },
@ -322,7 +313,7 @@ define(function(require, exports, module) {
skin: skins.password || "forminput", skin: skins.password || "forminput",
width: options.width || widths.password, width: options.width || widths.password,
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1 realtime: typeof options.realtime !== "undefined" ? options.realtime : 1
}) })
@ -334,9 +325,15 @@ define(function(require, exports, module) {
new ui.colorbox({ new ui.colorbox({
width: options.width || widths.colorbox, width: options.width || widths.colorbox,
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1 realtime: typeof options.realtime !== "undefined" ? options.realtime : 1,
onafterchange: function(e) {
if (options.path)
settings.set(options.path, e.value);
if (options.onchange)
options.onchange({ value: e.value });
},
}) })
]; ];
break; break;
@ -395,7 +392,7 @@ define(function(require, exports, module) {
width: options.width || widths.textarea, width: options.width || widths.textarea,
height: options.height || 200, height: options.height || 200,
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1 realtime: typeof options.realtime !== "undefined" ? options.realtime : 1
}) })
@ -417,7 +414,7 @@ define(function(require, exports, module) {
? "font-family: Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace; font-size: 10px" ? "font-family: Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace; font-size: 10px"
: "", : "",
value: options.path value: options.path
? createBind(options.path) ? settings.get(options.path)
: (options.defaultValue || ""), : (options.defaultValue || ""),
realtime: typeof options.realtime !== "undefined" ? options.realtime : 1 realtime: typeof options.realtime !== "undefined" ? options.realtime : 1
}) })
@ -462,21 +459,11 @@ define(function(require, exports, module) {
var dropdown = el.lastChild; var dropdown = el.lastChild;
if (item.items) { if (item.items) {
var data = item.items.map(function(item) { dropdown.setChildren(item.items);
return "<item value='" + item.value
+ "'><![CDATA[" + item.caption + "]]></item>"; var value = item.value || dropdown.value;
}).join(""); dropdown.value = -999;
if (data) { dropdown.setAttribute("value", value);
setTimeout(function() {
dropdown.$model.load("<items>" + data + "</items>");
setTimeout(function() {
var value = item.value || dropdown.value;
dropdown.value = -999;
dropdown.setAttribute("value", value);
});
});
}
} }
else if (item.value) { else if (item.value) {
dropdown.setAttribute("value", item.value); dropdown.setAttribute("value", item.value);

Wyświetl plik

@ -104,10 +104,6 @@ apf.ChildValue = function(){
this.$norecur = true; this.$norecur = true;
if (v.indexOf("{") > -1 || v.indexOf("[") > -1)
this.$setDynamicProperty(this.$childProperty, v);
else
if (this[this.$childProperty] != v) if (this[this.$childProperty] != v)
this.setProperty(this.$childProperty, v); this.setProperty(this.$childProperty, v);
@ -144,13 +140,8 @@ apf.ChildValue = function(){
v = m && m[2] || ""; v = m && m[2] || "";
if (m && m[1]) if (m && m[1])
v = "{" + v + "}"; v = "{" + v + "}";
if (v.indexOf("{") > -1 || v.indexOf("[") > -1) this.setProperty(this.$childProperty, apf.html_entity_decode(v)); //@todo should be xml entity decode
this.$setDynamicProperty(this.$childProperty, v);
else
this.setProperty(this.$childProperty, apf.html_entity_decode(v)); //@todo should be xml entity decode
} }
else if (hasNoProp) else if (hasNoProp)
this.$propHandlers[this.$childProperty].call(this, ""); this.$propHandlers[this.$childProperty].call(this, "");
@ -491,6 +482,10 @@ apf.dropdown = function(struct, tagName) {
this.addEventListener("popuphide", this.slideUp); this.addEventListener("popuphide", this.slideUp);
this.setChildren = function(data) {
};
// *** Keyboard Support *** // // *** Keyboard Support *** //

Wyświetl plik

@ -1298,51 +1298,7 @@ apf.item = function(struct, tagName) {
* ``` * ```
*/ */
this.$propHandlers["hotkey"] = function(value) { this.$propHandlers["hotkey"] = function(value) {
if (!this.$amlLoaded) {
var _self = this;
this.addEventListener("DOMNodeInsertedIntoDocument", function(e) {
if (_self.$hotkey && _self.hotkey)
apf.setNodeValue(this.$hotkey, apf.isMac
? apf.hotkeys.toMacNotation(_self.hotkey) : _self.hotkey);
});
}
else if (this.$hotkey)
apf.setNodeValue(this.$hotkey, apf.isMac ? apf.hotkeys.toMacNotation(value) : value);
if (this.$lastHotkey) {
apf.hotkeys.remove(this.$lastHotkey[0], this.$lastHotkey[1]);
delete this.$lastHotkey[0];
}
if (value) {
this.$lastHotkey = [value];
var _self = this;
apf.hotkeys.register(value, this.$lastHotkey[1] = function() {
if (_self.disabled || !_self.visible)
return;
//hmm not very scalable...
if (_self.parentNode) {
var buttons = apf.document.getElementsByTagNameNS(apf.ns.aml, "button");
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].submenu == _self.parentNode.name) {
var btn = buttons[i];
btn.$setState("Over", {});
$setTimeout(function() {
btn.$setState("Out", {});
}, 200);
break;
}
}
}
_self.$down();
_self.$up();
_self.$click();
});
}
}; };
/** /**

Wyświetl plik

@ -1009,14 +1009,9 @@ apf.Class.prototype = new (function(){
//Check if property has changed //Check if property has changed
if (isChanged) { if (isChanged) {
if (setAttr && !this.$funcHandlers[prop])
this.setAttribute(prop, value, true);
if (this.$handlePropSet(prop, value, forceOnMe) === false) if (this.$handlePropSet(prop, value, forceOnMe) === false)
return; return;
value = this[prop]; value = this[prop];
} }
@ -1342,17 +1337,13 @@ apf.Class.prototype = new (function(){
//Remove dynamic properties //Remove dynamic properties
/*var f, i, l, h; for (var prop in this.$funcHandlers) {
for (prop in this.$funcHandlers) { var f = this.$funcHandlers[prop];
h = this.$funcHandlers[prop];
//Remove any bounds if relevant //Remove any bounds if relevant
if (h && typeof h != FUN) { if (f && f.amlNode) {
for (i = 0, l = h.length; i < l; i++) { f.amlNode.removeEventListener(PROP + f.prop, f.handler);
(f = h[i]).amlNode.removeEventListener(PROP + f.prop, f.handler);
}
} }
}*/ }
if (this.attributes) { if (this.attributes) {
@ -1372,9 +1363,9 @@ apf.Class.prototype = new (function(){
} }
catch (ex) {} catch (ex) {}
for (var prop in this.$captureStack) this.$captureStack[prop] = null; this.$eventsStack = {};
for (var prop in this.$eventsStack) this.$eventsStack[prop] = null; this.$captureStack = {};
for (var prop in this.$funcHandlers) this.$funcHandlers[prop] = null; this.$funcHandlers = {};
if (this.$bufferEvents) { if (this.$bufferEvents) {
for (var i = this.$bufferEvents.length - 1; i >= 0; i--) for (var i = this.$bufferEvents.length - 1; i >= 0; i--)
@ -4192,106 +4183,6 @@ apf.getInheritedAttribute = function(xml, attr, func) {
: result; : result;
}; };
/**
* Creates an XML node based on an xpath statement.
*
* @param {DOMNode} contextNode The DOM node that is subject to the query
* @param {String} xPath The xpath query
* @param {Array} [addedNodes] An array that is filled with the added nodes
* @param {Boolean} [forceNew] Defines whether a new node is always created
* @return {DOMNode} The last element found
*/
apf.createNodeFromXpath = function(contextNode, xPath, addedNodes, forceNew) {
// @todo generalize this to include attributes in if format []
var xmlNode, foundpath = "", paths = xPath.replace(/('.*?')|(".*?")|\|/g, function(m, m1, m2) {
if (m1 || m2) return m1 || m2;
return "-%-|-%-";
}).split("-%-|-%-")[0].replace(/('.*?')|(".*?")|\/(?!\/)/g, function(m, m1, m2) {
if (m1 || m2) return m1 || m2;
return "-%-|-%-";
}).split("-%-|-%-");
if (!forceNew && (xmlNode = contextNode.selectSingleNode(xPath)))
return xmlNode;
var len = paths.length - 1;
if (forceNew) {
if (paths[len].trim().match(/^\@(.*)$|^text\(\)$/))
len--;
}
//Directly forwarding to the document element because of a bug in the o3 xml lib
if (!paths[0]) {
contextNode = contextNode.ownerDocument.documentElement;
paths.shift();paths.shift();
len--;len--;
}
for (var addedNode, isAdding = false, i = 0; i < len; i++) {
if (!isAdding && contextNode.selectSingleNode(foundpath
+ (i != 0 ? "/" : "") + paths[i])) {
foundpath += (i != 0 ? "/" : "") + paths[i];// + "/";
continue;
}
//Temp hack
var isAddId = paths[i].match(/(\w+)\[@([\w-]+)=(\w+)\]/);
if (isAddId)
paths[i] = isAddId[1];
isAdding = true;
addedNode = contextNode.selectSingleNode(foundpath || ".")
.appendChild(contextNode.ownerDocument.createElement(paths[i]));
if (isAddId) {
addedNode.setAttribute(isAddId[2], isAddId[3]);
foundpath += (foundpath ? "/" : "") + isAddId[0];// + "/";
}
else
foundpath += (foundpath ? "/" : "") + paths[i];// + "/";
if (addedNodes)
addedNodes.push(addedNode);
}
if (!foundpath)
foundpath = ".";
if (addedNodes)
addedNodes.foundpath = foundpath;
var newNode, lastpath = paths[len],
doc = contextNode.nodeType == 9 ? contextNode : contextNode.ownerDocument;
do {
if (lastpath.match(/^\@(.*)$/)) {
(newNode || contextNode.selectSingleNode(foundpath))
.setAttributeNode(newNode = doc.createAttribute(RegExp.$1));
}
else if (lastpath.trim() == "text()") {
newNode = (newNode || contextNode.selectSingleNode(foundpath))
.appendChild(doc.createTextNode(""));
}
else {
var hasId = lastpath.match(/(\w+)\[@([\w-]+)=(\w+)\]/);
if (hasId) lastpath = hasId[1];
newNode = (newNode || contextNode.selectSingleNode(foundpath))
.appendChild(doc.createElement(lastpath));
if (hasId)
newNode.setAttribute(hasId[2], hasId[3]);
}
if (addedNodes)
addedNodes.push(newNode);
foundpath += (foundpath ? "/" : "") + paths[len];
} while ((lastpath = paths[++len]));
return newNode;
};
/** /**
* Returns the first text or cdata child of a [[term.datanode data node]]. * Returns the first text or cdata child of a [[term.datanode data node]].
* *
@ -8981,14 +8872,7 @@ apf.AmlElement = function(struct, tagName) {
this.$inheritProperties[prop] = 2; this.$inheritProperties[prop] = 2;
if (value) { if (value) {
this.setProperty(prop, value, false, false, 2);
if (typeof value == "string"
&& (value.indexOf("{") > -1 || value.indexOf("[") > -1)) {
this.$setDynamicProperty(prop, value);
}
else
this.setProperty(prop, value, false, false, 2);
} }
return value; return value;
@ -9263,15 +9147,7 @@ apf.AmlAttr = function(ownerElement, name, value) {
return; return;
} }
if (host.localName != "page" && typeof value == "string" && ( host.setProperty(name, value); //@todo apf3.0 is this a lot slower?
(value.indexOf("{") > -1 || value.indexOf("[") > -1)))
host.$setDynamicProperty(name, value);
else
{
host.setProperty(name, value); //@todo apf3.0 is this a lot slower?
}
//host.$handlePropSet(name, value);
if (this.specified) { if (this.specified) {
//@todo apf3.0 domattr - slow? //@todo apf3.0 domattr - slow?
@ -17190,51 +17066,6 @@ apf.button = function(struct, tagName) {
}; };
/**
* @attribute {String} hotkey Sets or gets the key combination a user can press
* to active the function of this element. Use any combination of
* [[keys: Ctrl]], [[keys: Shift]], [[keys: Alt]], [[keys: F1]]-[[keys: F12]], and alphanumerical characters. Use a
* space, a minus or plus sign as a seperator.
*
* #### Example
*
* ```xml
* <a:button hotkey="Ctrl-Z">Undo</a:button>
* ```
*/
this.$propHandlers["hotkey"] = function(value) {
if (this.$hotkey)
apf.setNodeValue(this.$hotkey, value);
if (this.$lastHotkey) {
apf.hotkeys.remove(this.$lastHotkey[0], this.$lastHotkey[1]);
delete this.$lastHotkey[0];
}
if (value) {
this.$lastHotkey = [value];
var _self = this;
apf.hotkeys.register(value, this.$lastHotkey[1] = function(){
//hmm not very scalable...
_self.$setState("Over", {});
$setTimeout(function(){
_self.$setState("Out", {});
}, 200);
if (_self.$clickHandler && _self.$clickHandler())
_self.$updateState(e || event, "click");
else
_self.dispatchEvent("click");
});
}
if (this.tooltip)
apf.GuiElement.propHandlers.tooltip.call(this, this.tooltip);
}
//@todo move this to menu.js //@todo move this to menu.js
function menuKeyHandler(e) { function menuKeyHandler(e) {
@ -17729,6 +17560,7 @@ apf.checkbox = function(struct, tagName) {
this.change = this.change =
this.setValue = function(value) { this.setValue = function(value) {
this.setProperty("value", value, false, true); this.setProperty("value", value, false, true);
this.dispatchEvent("afterchange", { value: value });
}; };
/** /**
@ -20868,7 +20700,8 @@ apf.spinner = function(struct, tagName) {
*/ */
this.change = this.change =
this.setValue = function(value) { this.setValue = function(value) {
this.setProperty("value", value, false, true); this.setProperty("value", value, false, true);
this.dispatchEvent("afterchange", { value: value });
}; };
/** /**

Wyświetl plik

@ -1,3 +1,4 @@
/*global apf*/
define(function(require, exports, module) { define(function(require, exports, module) {
main.consumes = ["Plugin", "settings", "commands", "layout", "anims", "ui", "c9"]; main.consumes = ["Plugin", "settings", "commands", "layout", "anims", "ui", "c9"];
main.provides = ["menus", "Menu", "MenuItem", "Divider"]; main.provides = ["menus", "Menu", "MenuItem", "Divider"];
@ -48,13 +49,44 @@ define(function(require, exports, module) {
// Hook deep into APF to make hotkeys work as we want // Hook deep into APF to make hotkeys work as we want
function formatHotkey(value) {
if (value && /^commands./.test(value))
value = commands.getHotkey(value.slice(9));
if (apf.isMac && value)
value = apf.hotkeys.toMacNotation(value);
return value;
}
function addHotkeyListener(amlNode, value) {
var oldHandler = amlNode.$funcHandlers.hotkey;
if (oldHandler && oldHandler.value != value) {
commands.commandManager.off("prop." + oldHandler.prop, oldHandler.handler);
}
if (value && /^commands./.test(value)) {
// TODO replace this with the mechanism from events
oldHandler = amlNode.$funcHandlers.hotkey = oldHandler || {
handler: function(e) {
amlNode.$propHandlers["hotkey"].call(amlNode, amlNode.hotkey);
}
};
oldHandler.prop = value.slice(9);
oldHandler.amlNode = commands.commandManager;
commands.commandManager.on("prop." + oldHandler.prop, oldHandler.handler);
}
}
apf.button.prototype.$propHandlers["hotkey"] = function(value) { apf.button.prototype.$propHandlers["hotkey"] = function(value) {
if (this.$hotkey) if (this.$hotkey)
apf.setNodeValue(this.$hotkey, apf.isMac apf.setNodeValue(this.$hotkey, formatHotkey(value));
? apf.hotkeys.toMacNotation(this.hotkey) : this.hotkey); this.$propHandlers["tooltip"].call(this, this.tooltip);
addHotkeyListener(this, value);
if (this.tooltip) };
apf.GuiElement.propHandlers.tooltip.call(this, this.tooltip); apf.button.prototype.$propHandlers["tooltip"] = function(value) {
if (this.$ext) {
var hotkey = formatHotkey(this.hotkey);
this.$ext.setAttribute("title", (this.tooltip || "")
+ (hotkey ? " (" + hotkey + ")" : ""));
}
}; };
apf.item.prototype.$propHandlers["hotkey"] = function(value) { apf.item.prototype.$propHandlers["hotkey"] = function(value) {
@ -62,13 +94,12 @@ define(function(require, exports, module) {
var _self = this; var _self = this;
this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { this.addEventListener("DOMNodeInsertedIntoDocument", function(e) {
if (_self.$hotkey && _self.hotkey) if (_self.$hotkey && _self.hotkey)
apf.setNodeValue(this.$hotkey, apf.isMac apf.setNodeValue(this.$hotkey, formatHotkey(_self.hotkey));
? apf.hotkeys.toMacNotation(this.hotkey) : this.hotkey);
}); });
} }
else if (this.$hotkey) else if (this.$hotkey)
apf.setNodeValue(this.$hotkey, apf.setNodeValue(this.$hotkey, formatHotkey(value));
apf.isMac ? apf.hotkeys.toMacNotation(value || "") : value); addHotkeyListener(this, value);
}; };
apf.splitbutton.prototype.$propHandlers["command"] = apf.splitbutton.prototype.$propHandlers["command"] =
@ -80,9 +111,7 @@ define(function(require, exports, module) {
return; return;
} }
// TODO this.setAttribute("hotkey", value && "commands." + value || "");
// this.setAttribute("hotkey",
// value && "{commands.commandManager." + value + "}" || "");
this.onclick = function(e) { this.onclick = function(e) {
if (e && e.htmlEvent && e.htmlEvent.button) return; if (e && e.htmlEvent && e.htmlEvent.button) return;
@ -90,7 +119,7 @@ define(function(require, exports, module) {
var command = commands.commands[value]; var command = commands.commands[value];
if (command && command.focusContext) if (command && command.focusContext)
emit("focusEditor"); emit("focusEditor");
} || null; };
}; };
settings.on("read", function(e) { settings.on("read", function(e) {
@ -395,7 +424,7 @@ define(function(require, exports, module) {
if (itemName != "~") { if (itemName != "~") {
if (debug) if (debug)
itemName = "(" + index + ") " + itemName; itemName = "(" + index + ") " + itemName;
item.setAttribute("caption", itemName.replace(/[\[\]]/, "\\$&")); item.setAttribute("caption", itemName);
} }
} }

Wyświetl plik

@ -597,15 +597,6 @@ define(function(require, module, exports) {
*/ */
insertByIndex: insertByIndex, insertByIndex: insertByIndex,
/**
* @ignore
*/
n: apf.n,
/**
* @ignore
*/
b: apf.b,
/** /**
* Escapes "&amp;", greater than, less than signs, quotation marks, * Escapes "&amp;", greater than, less than signs, quotation marks,
@ -741,11 +732,6 @@ define(function(require, module, exports) {
*/ */
removeClass: removeClass, removeClass: removeClass,
/**
* @ignore
*/
createNodeFromXpath: apf.createNodeFromXpath,
/** /**
* Determines whether a string is true (in the HTML attribute sense). * Determines whether a string is true (in the HTML attribute sense).
* @param {Mixed} value The variable to check. Possible truth values include: * @param {Mixed} value The variable to check. Possible truth values include:
@ -774,10 +760,6 @@ define(function(require, module, exports) {
*/ */
isFalse: apf.isFalse, isFalse: apf.isFalse,
/**
* @ignore
*/
getCleanCopy: apf.getCleanCopy,
/** /**
* This method retrieves the current value of a CSS property on an * This method retrieves the current value of a CSS property on an