3.2.0

oncontextmenu

Amazing, This is a very cool and capable widget. I am trying to use the oncontextmenu event however I have some issues mainly with by brain as jscript is not my primary language

I instate the event handler for oncontextmenu like so

obj.setEvent("oncontextmenu", "window.event.cancelBubble=true;showmycontext(this);return false;");


Now the problem I know 'this' is not returning what I expect it returns className: active-controls-grid
However I want to be able to access the methods of the grid such as my event handler can do things like
function showmycontext(src) {
alert( src.getProperty("item/text") );
}

Any clues or assistance would be great
November 30,
Instead of working directly with ‘oncontextmenu’ event I would solve this in two steps. First, on the cell level translate HTML ‘oncontextmenu’ event into the new ActiveWidgets ‘contextmenu’ action. Second – catch this action on the grid object level (action bubbles up through ActiveWidgets templates similar to HTML events). Actions carry the source template reference in the first argument – so in the action handler I will have access to both the grid (as ‘this’) and the cell (as ‘src’).

Here is the script:

// define event handler for oncontextmenu event
function oncontextmenu(event){
event.cancelBubble = true;
event.returnValue = false;
this.action("contextmenu");
}

// assign the event handler to the cell template prototype
Active.Templates.Text.prototype.setEvent("oncontextmenu", oncontextmenu);

// create action handler
obj.setAction("contextmenu", function(src){alert(src.getProperty("item/text"))});


Alex (ActiveWidgets)
November 30,
Fantastic, you genius....

Thanks that worked a charm

December 1,
How do you setup an oncontextmenu with version 2.0? I've tried the 1.0 code, but I get errors.
George Belardo
November 18,

This topic is archived.

See also:


Back to support forum