新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论SVG, GML, X3D, VRML, VML, XAML, AVALON, Batik等基于XML的图形技术,以及有关GIS的应用。
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - 高级XML应用『 SVG/GML/VRML/X3D/XAML 』 → [转帖]Customizing the Adobe SVG Viewer Context Menu 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2971 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [转帖]Customizing the Adobe SVG Viewer Context Menu 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     SCYANGYU 帅哥哟,离线,有人找我吗?处女座1971-9-20
      
      
      威望:7
      等级:大四(每天看1小时莱昂氏)
      文章:217
      积分:1281
      门派:XML.ORG.CN
      注册:2005/2/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给SCYANGYU发送一个短消息 把SCYANGYU加入好友 查看SCYANGYU的个人资料 搜索SCYANGYU在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看SCYANGYU的博客楼主
    发贴心情 [转帖]Customizing the Adobe SVG Viewer Context Menu

    Customizing the Adobe SVG Viewer Context Menu

    Starting with version 3.0 of the Adobe SVG Viewer, SVG authors are allowed to modify the menu that pops up when the user right-clicks on the SVG.

    Before you do this, however, you would do well to keep in mind some common-sense guidelines (as posted by MichaelBierman and others on the SVG-Developers list):

    Don't hide the Help item
    Don't hide the About ASV item (Adobe and the people who created ASV deserve credit, and you might be violating the ASV EULA; also, the menu may not work)
    Don't rearrange the existing menu items (users should be able to depend on them being in the same order, etc.)
    Do turn off items that don't make sense (i.e. there is no need to Zoom or Pan on some content--it will just "break"); however, keep in mind that visually impaired users may need to zoom in to see your content
    Tips:

    Disabling, rather than removing, items provides a consistant interface without allowing users to perform unwanted actions, such as zooming or saving the SVG
    Customizing the Menu*
    First, you declare a <def> to define the new menu:

    <defs>
    <menu id='NewMenu' xmlns='http://foo' onload='GetPosition( evt )'>
      <header>Custom Menu</header>
      <item action='ZoomIn'>Zoom &amp;In</item>
      <item action='ZoomOut'>Zoom &amp;Out</item>
      <item action='OriginalView'>&amp;Original View</item>
      <separator />
      <item onactivate='MyFunction()'>&amp;My Function</item>
      <menu>
       <header>Submenu</header>
       <item onactivate="alert('Item1')">Item1</item>
       <item onactivate="alert('Item2')">Item2</item>
       <item onactivate="alert('Item3')">Item3</item>
      </menu>
      <separator />
      <item xmlns='http://www.w3.org/1999/xlink' xlink:href='inserted_link.html' target='resource window'>Menu Link...</item>
      <separator />
      <item action='Quality'>Higher &amp;Quality</item>
      <item action='Pause'>&amp;Pause</item>
      <item action='Mute'>&amp;Mute</item>
      <separator />
      <item action='Find'>&amp;Find...</item>
      <item action='FindAgain'>Find &amp;Again</item>
      <separator />
      <item action='CopySVG'>&amp;Copy SVG</item>
      <item action='ViewSVG'>&amp;View SVG...</item>
      <item action='ViewSource'>View Sourc&amp;e...</item>
      <item action='SaveAs'>&amp;Save SVG As...</item>
      <item action='SaveSnapshotAs'>Sa&amp;ve Current State...</item>
      <separator />
      <item action='Help'>&amp;Help...</item>
      <item action='About'>About SVG Viewer...</item>
    </menu>
    </defs>
    Several key points should be noted from the code above:

    Each entry on the menu is marked by an <item> tag.
    The <separator /> tag creates a separator bar on the menu.
    Nested <menu> tags create sub-menus; the header for these sub-menus is not selectable
    To access the built-in functions of the SVG Viewer, you include an 'action' property
    To access author-defined functions, you include an 'onactivate' property
    In order to insert a link on the menu, you must resolve the XML NameSpace for XLink and preface the link with 'xlink:'

    xmlns='http://www.w3.org/1999/xlink'
    xlink:href='inserted_link.html'
    In addition, each <item /> can have one or more of the following properties:

    checked='yes|no' --this indicated whether a particular option is active, as on the 'Higher Quality' option
    enabled='yes|no' --if this property is set to "no," the option will be visible, but grayed-oout, and can't be selected
    display='none|inline' --if this property is set to "none," the option will be not be visible

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

    Next, in order to use this menu, you must overwrite the original Context Menu with the new definition, in the script section of your SVG:

    <script>
    <![CDATA[
      var newMenuRoot = parseXML( printNode( document.getElementById( 'NewMenu' ) ), contextMenu );
      contextMenu.replaceChild( newMenuRoot, contextMenu.firstChild );
    ]]>
    </script>


       收藏   分享  
    顶(0)
      




    ----------------------------------------------
    http://borland.mblogger.cn/scyangyu/

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/2/27 11:12:00
     
     henrybenben 帅哥哟,离线,有人找我吗?
      
      
      等级:大二(研究C++)
      文章:50
      积分:257
      门派:XML.ORG.CN
      注册:2005/4/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给henrybenben发送一个短消息 把henrybenben加入好友 查看henrybenben的个人资料 搜索henrybenben在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看henrybenben的博客2
    发贴心情 
    thanks  a  lot!
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/13 23:27:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/2/27 21:06:19

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    62.500ms