以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  [转帖]Attribute contextMenu  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=14836)


--  作者:SCYANGYU
--  发布时间:2/27/2005 11:14:00 AM

--  [转帖]Attribute contextMenu
Attribute contextMenu

Synopsis:
readonly dom::Document contextMenu
XML document that represents SVG Viewer's context menu. Any change to this document will be reflected on the context menu (when it pops up). The document's root element must be a "menu" element. The following elements are allowed in menu:

header   menu header; most systems ignore header text content of this element will be visible on the menu on the systems that support menu headers  
item   an item in the menu text content of this element will be visible as item's text; character "&" designates hot key.  
separator   separator bar  
menu   submenu; some systems can flatten submenus  

item element can have following attributes (note that xlink:href attribute must be in XLink namespace, use only setAttributeNS to set it):

action   system action that this item will cause if activated  
onactivate   script that gets executed when this item is activated  
xlink:href   follow the specified URL  
target   used together with xlink:href  
checked   can be either "yes" or "now", will cause a checkmark be drawn next to this item  
display   can be either "inline" or "none"; if "none" this item is ignored  
enabled   can be either "yes" or "no"; if "no" this item is visible, but cannot be selected  

Supported system actions are listed here:

ZoomIn
ZoomOut
OriginalView
Quality
Pause
Mute
Find
FindAgain
Copy
CopySVG
ViewSVG
ViewSource
SaveAs
SaveOriginalAs
SaveSnapshotAs
Help
About
It is strongly recommended to have 'About' action in the menu. Menus without 'About' action may get ignored by the viewer.


--------------------------------------------------------------------------------

A (nearly-)complete, fairly generic example of this -including activation of the 'checked,' 'display,' and 'enabled' options- can be seen at http://www.svg-whiz.com/images/customcontextmenu.svg.


--------------------------------------------------------------------------------

Implementation Note: It is not possible in ASV3 to access the built-in functions of the context menu (such as "CopySVG" or "SaveAs") through script. This is a security feature.


--------------------------------------------------------------------------------

Disabling the Context Menu
To prevent the menu from appearing at all, you can use some variation of the following code:

<svg onmousedown="evt.preventDefault()" onmouseup="evt.preventDefault()">
   ...
</svg>
This can be useful when you want to provide your own context menu, or when you want the right-click to have another action.


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms