[Laszlo-checkins] r14366 - in openlaszlo/trunk: examples/extensions lps/components/extensions lps/includes/source
max@openlaszlo.org
max at openlaszlo.org
Wed Jul 22 13:23:23 PDT 2009
Author: max
Date: 2009-07-22 13:23:11 -0700 (Wed, 22 Jul 2009)
New Revision: 14366
Modified:
openlaszlo/trunk/examples/extensions/html.lzx
openlaszlo/trunk/lps/components/extensions/html.lzx
openlaszlo/trunk/lps/includes/source/iframemanager.js
Log:
Change 20090722-maxcarlson-N by maxcarlson at Bank.local on 2009-07-22 10:21:10 PDT
in /Users/maxcarlson/openlaszlo/trunk-clean
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Allow native context menus to be shown for the html tag
Bugs Fixed: LPP-8298 - In DHTML the html component should show the iframes right click menu, not the lzx right click menu
Technical Reviewer: hminsky
QA Reviewer: mdemmon
Details: lps/components/extensions/html.lzx - Add shownativecontextmenu attribute and setter, clarify documentation for mouseevents setter.
iframemanager.js - Add setShowNativeContextMenu() to receive and store state from the html component. Always show native context menus if set to true for a given iframe. Don't forward oncontextmenu events to Flash runtimes.
examples/extensions/html.lzx - Add button that toggles native context menus on/off to test the functionality.
Tests: examples/extensions/html.lzx - Clicking 'Toggle native context menus' works in dhtml. Clicking the 'Toggle native context menus' button in swf warns if the debugger is on. Right-clicking no longer warns about unhandled events in swf.
Modified: openlaszlo/trunk/examples/extensions/html.lzx
===================================================================
--- openlaszlo/trunk/examples/extensions/html.lzx 2009-07-22 19:22:02 UTC (rev 14365)
+++ openlaszlo/trunk/examples/extensions/html.lzx 2009-07-22 20:23:11 UTC (rev 14366)
@@ -62,6 +62,13 @@
}
</handler>
</button>
+ <button>Toggle native context menus (DHTML only)
+ <handler name="onclick">
+ if (classroot.main) {
+ classroot.main.setAttribute('shownativecontextmenu', ! classroot.main.shownativecontextmenu);
+ }
+ </handler>
+ </button>
<text name="status" y="3" fontstyle="bold" visible="${classroot.main.loading}">Loading...</text>
</hbox>
<html name="main" history="false" width="100%" height="${classroot.height - this.y - 44}">
Modified: openlaszlo/trunk/lps/components/extensions/html.lzx
===================================================================
--- openlaszlo/trunk/lps/components/extensions/html.lzx 2009-07-22 19:22:02 UTC (rev 14365)
+++ openlaszlo/trunk/lps/components/extensions/html.lzx 2009-07-22 20:23:11 UTC (rev 14366)
@@ -60,7 +60,13 @@
lz.Browser.callJS('lz.embed.iframemanager.setSendMouseEvents', null, id, send);
}
-
+lz.embed.iframemanager.setShowNativeContextMenu = function(id, show, showwarning) {
+ <![CDATA[
+ if ($debug && showwarning) {
+ Debug.warn("The shownativecontextmenu attribute won't work in runtimes other than dhtml.");
+ }
+ ]]>
+}
</script>
</otherwise>
</switch>
@@ -121,7 +127,7 @@
@access number
-->
<attribute name="minimumwidth" type="number" value="0"/>
- <!--- If true, attempt to listen for mouse events on the iframe
+ <!--- If true, attempt to listen for mouse events on the iframe. Cross-domain security restrictions apply, so if the content loaded in the iframe is from a different domain, mouse events won't be sent.
@type Boolean
@access boolean
-->
@@ -137,7 +143,22 @@
if (this['onmouseevents'] && this.onmouseevents.ready) this.onmouseevents.sendEvent(send);
]]>
</setter>
-
+ <!--- If true, show native context menus in the iframe. Otherwise, show OpenLaszlo context menus. Note that this only works in DHTML because it's not possible to programatically display a context menu in Flash.
+ @type Boolean
+ @access boolean
+ -->
+ <attribute name="shownativecontextmenu" type="boolean" value="true"/>
+ <setter name="shownativecontextmenu" args="show">
+ <![CDATA[
+ this.shownativecontextmenu = show;
+ if (this['iframeid']) {
+ lz.embed.iframemanager.setShowNativeContextMenu(this.iframeid, show, true);
+ } else {
+ this.__shownativecontextmenu = show;
+ }
+ if (this['onshownativecontextmenu'] && this.onshownativecontextmenu.ready) this.onshownativecontextmenu.sendEvent(show);
+ ]]>
+ </setter>
<!--- Sets the view to listen to for x/y/width/height change events. Defaults to this.parent.
@type LzView
@access public
@@ -243,6 +264,7 @@
}
this.setAttribute('ready', true);
if (this['__mouseevents']) lz.embed.iframemanager.setSendMouseEvents(id, this.__mouseevents);
+ if (this['__shownativecontextmenu']) lz.embed.iframemanager.setShowNativeContextMenu(id, this.__shownativecontextmenu);
</method>
<!--- @access private -->
<method name="__gotload">
Modified: openlaszlo/trunk/lps/includes/source/iframemanager.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/iframemanager.js 2009-07-22 19:22:02 UTC (rev 14365)
+++ openlaszlo/trunk/lps/includes/source/iframemanager.js 2009-07-22 20:23:11 UTC (rev 14366)
@@ -10,6 +10,7 @@
,__callqueue: {}
,__calljsqueue: {}
,__sendmouseevents: {}
+ ,__hidenativecontextmenu: {}
,create: function(owner, name, scrollbars, appendto, defaultz, canvasref) {
//console.log(owner + ', ' + name + ', ' + scrollbars + ', ' + appendto + ', ' + defaultz)
var id = '__lz' + lz.embed.iframemanager.__counter++;
@@ -329,7 +330,8 @@
}
}
,__mouseEvent: function(e, id) {
- var iframe = lz.embed.iframemanager.getFrame(id);
+ var lze = lz.embed;
+ var iframe = lze.iframemanager.getFrame(id);
if (! iframe) return;
if (!e) {
@@ -340,9 +342,13 @@
if (iframe.owner && iframe.owner.sprite && iframe.owner.sprite.__mouseEvent) {
// dhtml
if (eventname == 'oncontextmenu') {
- var pos = lz.embed.getAbsolutePosition(iframe);
- LzMouseKernel.__sendMouseMove(e, pos.x, pos.y)
- return LzMouseKernel.__showContextMenu(e);
+ if (! lze.iframemanager.__hidenativecontextmenu[id]) {
+ return;
+ } else {
+ var pos = lze.getAbsolutePosition(iframe);
+ LzMouseKernel.__sendMouseMove(e, pos.x, pos.y)
+ return LzMouseKernel.__showContextMenu(e);
+ }
}
iframe.owner.sprite.__mouseEvent(e);
@@ -358,8 +364,10 @@
eventname = 'onmouseout';
} else if (eventname == 'onmouseenter') {
eventname = 'onmouseover';
+ } else if (eventname == 'oncontextmenu') {
+ return;
}
- lz.embed[iframe.owner].callMethod('lz.embed.iframemanager.__gotMouseEvent(\'' + id + '\',\'' + eventname + '\')');
+ lze[iframe.owner].callMethod('lz.embed.iframemanager.__gotMouseEvent(\'' + id + '\',\'' + eventname + '\')');
}
}
,setSendMouseEvents: function(id, send) {
@@ -420,4 +428,7 @@
}
}
}
+ ,setShowNativeContextMenu: function(id, show) {
+ this.__hidenativecontextmenu[id] = ! show;
+ }
}
More information about the Laszlo-checkins
mailing list