PopupMenuHandler and PopupMenuHandlerNamespace
properties are used to specify the script function that will inspect
the context menu requests made by the page(s). Note
that this technique is not fully compatible with Internet Explorer 4
- see the remarks section for details. Use DisplayPopupMenu
method if you want full compatibility with all the supported Internet
Explorer versions (4.0 and later).
Syntax and description
external.PopupMenuHandler - string - Read/Write. Specifies the
script function to be called to handle the notification. Only the
function name must be specified (no brackets or parameters). For
example:
external.PopupMenuHandler = "MyPopupMenuHandler";
In the page function should be defined as:
function MyPopupMenuHandler(firingElment) {
// Implementation ...
}
See below what the function must do in order to select the menu.
external.PopupMenuHandlerNamespace - string - Read/Write.
Specifies the namespace that holds the function specified in the PopupMenuHandler
property. the string syntax is "namespacetype=namespacename".
Currently only frame is supported as namespace type. In case of
no frames property should be empty (i.e. care about it only if you
have frames). Example:
external.PopupMenuHandlerNamespace = "frame=main";
If you have a FRAMESET with a frame called "main" or
IFRAME with that name.
The handler function
Function prototype is:
function PopupMenuHanlerFunctionName(elementClicked)
{ ... }
The parameter elementClicked passes to it reference to the
object in the DHTML page clicked by the user. Function is called
when user clicks with the right mouse button somewhere in the page(s).
By inspecting the passed object function is able to determine what
context menu must be used and it must return VarioMenuItem
object from the menu tree. For example:
function MyPopupHandler( elClicked ) {
if (elClicked.tagName == "IMG") return external.Menus.MenuTree.Subs("MyPopupMenus")("ImagePopupMenu");
if (elClicked.tagName == "P") return external.Menus.MenuTree.Subs("MyPopupMenus")("ParagraphPopupMenu");
return null;
}
This example code selects previously defined branches of the menu
tree to be used as context menu for the object depending on its HTML
tag type. It selects some menus for the IMG and P elements and
returns null for all other elements. Returning null
means "don't show context menu".
Remarks
If Internet Explorer 4.x is installed on the machine
running the ALPFrame handler function receives as elementClicked
only whose DHTML elements that are able to gain focus - i.e. links
(A tags), form fields (INPUT, SELECT, TEXTAREA), body (BODY). If the
element can not be focused then the the first focusing capable
element containing the clicked element is returned. Usually this
will be the BODY - document itself instead of the clicked element.
IE 4.x doesn't support some coordinate mapping features required to
implement element recognition safe enough. Using the alternative way
- DisplayPopupMenu
method is recommended if the compatibility with IE 4.x is a
requirement.
Most developers will choose DisplayPopupMenu because its usage is
easier. But using popup menu handlers can help to the advanced
programmers to safe some work by omitting the code that shows the
menu and only implementing a selection routine - the popup menu
handler. The same result can be achieved using the DisplayPopupMenu
method:
Use the onMouseup DHTML event. Specify a handler routine
in the BODY element only:
<BODY onMouseup="MyHandler">
Write the MyHandler function:
function MyHandler() {
if (event.button != 2) return;
// If the mouse button pressed is not the right button do
nothing
// Use the event.srcElement to recognize the clicked object
// For example (as in the above example):
var popups = external.Menus.MenuTree.Subs("MyPopupMenus");
switch (elClicked.tagName) {
case "IMG":
DisplayPopupMenu(popups("ImagePopupMenu");
break;
case "P":
DisplayPopupMenu(popups("ParagraphPopupMenu");
break;
}
}
Applies to: external
|