contextMenu Implementation
//Add to body
/****** copy cell content to clipBoard *****/
obj.onKeyCtrlC = function(event){
var c = this.getCurrentColumn();
var r = this.getCurrentRow();
copyToClipBoard(this.getCellText(c, r));
AW.setReturnValue(event, false); // prevent default
}
/****** Copies text to system clipboard *****/
function copyToClipBoard(text) {
if (window.clipboardData) {
// the IE-manier
window.clipboardData.setData("Text", text);
}
return false;
}
obj.getCellTemplate().setEvent("oncontextmenu", function(event,column,row) {
event.cancelBubble = true;
event.returnValue = false;
initContextMenu(event.x,event.y,event);
});
function initContextMenu(x,y,e) {
showmenuie5();
document.body.onclick = hidemenuie5;
}
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">
<div class="menuitems" id="copy">Copy</div>
<div class="menuitems" id="paste">Paste</div>
<div class="menuitems" id="customize">Customize</div>
</div>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;
}
</script>
//Add this to header
<style>
<!--
.skin0 {
position:absolute;
text-align:left;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:5px;
padding-right:10px;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Begin
var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url) {
//window.status = event.srcElement.url;
}
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null) {
// window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
}
else {
if(event.srcElement.id=="copy")
obj.raiseEvent("onKeyCtrlC");
else if(event.srcElement.id=="paste")
obj.raiseEvent("onKeyCtrlV");
else if(event.srcElement.id=="customize")
changePreferences(obj);
}
}
}
// End -->
</script>
/****** copy cell content to clipBoard *****/
obj.onKeyCtrlC = function(event){
var c = this.getCurrentColumn();
var r = this.getCurrentRow();
copyToClipBoard(this.getCellText(c, r));
AW.setReturnValue(event, false); // prevent default
}
/****** Copies text to system clipboard *****/
function copyToClipBoard(text) {
if (window.clipboardData) {
// the IE-manier
window.clipboardData.setData("Text", text);
}
return false;
}
obj.getCellTemplate().setEvent("oncontextmenu", function(event,column,row) {
event.cancelBubble = true;
event.returnValue = false;
initContextMenu(event.x,event.y,event);
});
function initContextMenu(x,y,e) {
showmenuie5();
document.body.onclick = hidemenuie5;
}
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">
<div class="menuitems" id="copy">Copy</div>
<div class="menuitems" id="paste">Paste</div>
<div class="menuitems" id="customize">Customize</div>
</div>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;
}
</script>
//Add this to header
<style>
<!--
.skin0 {
position:absolute;
text-align:left;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:5px;
padding-right:10px;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Begin
var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url) {
//window.status = event.srcElement.url;
}
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null) {
// window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
}
else {
if(event.srcElement.id=="copy")
obj.raiseEvent("onKeyCtrlC");
else if(event.srcElement.id=="paste")
obj.raiseEvent("onKeyCtrlV");
else if(event.srcElement.id=="customize")
changePreferences(obj);
}
}
}
// End -->
</script>
Vikramaditya Garg
July 28,