You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


TOC PREV NEXT INDEX

Embedding Gecko API


nsIContextMenuListener


An optional interface for embedding clients who wish to receive notifications for context menu events, i.e. generated by a user right-mouse clicking on a link. The embedder implements this interface on the WebBrowser chrome object associated with the window for which notifications are required. When a context menu event occurs, the browser will call this interface if present. This interface is not scriptable.

See also: nsIDOMNode, nsIDOMEvent

Methods
onShowContextMenu

Called when the browser receives a context menu event (i.e. the user is right-mouse clicking somewhere on the document). The combination of flags, events and nodes provided in the call indicate where and what was clicked on.

The following table describes what context flags and node combinations are possible.

aContextFlag
aNode
CONTEXT_LINK
<A>
CONTEXT_IMAGE
<IMG>
CONTEXT_IMAGE | CONTEXT_LINK
<IMG> with an <A>
CONTEXT_INPUT
<INPUT>
CONTEXT_TEXT
<TEXTAREA>
CONTEXT_DOCUMENT
<HTML>

Syntax:

void nsIContextMenuListener::onShowContextMenu(
	in unsigned long aContextFlags, in nsIDOMEvent aEvent,
	in nsIDOMNode aNode )  

Parameters:

aContextFlags: Flags indicating the kind of context. See below.
aEvent:The DOM context menu event.
aNode: The DOM node most relevant to the context.

nsresult:

NS_OK always.
Constants
const unsigned long nsIContextMenuListener::CONTEXT_NONE=0

No context.

const unsigned long nsIContextMenuListener::CONTEXT_LINK=1

Context is a link element.

const unsigned long nsIContextMenuListener::CONTEXT_IMAGE=2

Context is an image element.

const unsigned long nsIContextMenuListener::CONTEXT_DOCUMENT=4

Context is the whole document.

const unsigned long nsIContextMenuListener::CONTEXT_TEXT=8

Context is a text area element.

const unsigned long nsIContextMenuListener::CONTEXT_INPUT=16

Context is an input element.


Written by:Ellen Evans | Comments, questions, complaints? Bug 143387
TOC PREV NEXT INDEX