{"id":15,"date":"2007-04-04T14:41:57","date_gmt":"2007-04-04T22:41:57","guid":{"rendered":"http:\/\/www.antunkarlovac.com\/blog\/?p=15"},"modified":"2007-04-04T14:43:34","modified_gmt":"2007-04-04T22:43:34","slug":"context-menu-guidelines","status":"publish","type":"post","link":"https:\/\/www.antunkarlovac.com\/blog\/2007\/04\/04\/context-menu-guidelines\/","title":{"rendered":"Context Menu Guidelines"},"content":{"rendered":"<p>OpenLaszlo allows users to define custom context menu (i.e. right-click menu) options throughout your applications. There&#8217;s two classes involved here: LzContextMenu and LzContextMenuItem. The former represents the context menu itself, and the latter represents a single option within it.<\/p>\n<p>Some capabilities and guidelines:<\/p>\n<ul>\n<li>Stick to Flash Player 8 or DHTML for your runtime, if you plan to use custom context menus in your application.<\/li>\n<li>Right-click behavior works very differently from left-click behavior: The view need not be clickable to respond to right-clicks. However all views, clickable or not, intercept the right mouse click. This means that a subview will <em>always<\/em> trap a right-click event before its parent.<\/li>\n<li>You can specify a context menu on a per-view basis. You can also specify a generic application-level context menu.<\/li>\n<li>There are some words you cannot seem to use as LzContextMenuItem captions. &#8220;Save&#8221; and &#8220;Delete&#8221; are two I came across. You can add a space character the name &#8211; e.g. &#8220;Save  &#8221; &#8211; to work around this.<\/li>\n<li>Views have a <strong>.contextMenu<\/strong> attribute as well as <strong>getContextMenu()<\/strong> and <strong>setContextMenu()<\/strong> methods.<\/li>\n<li>Context menus can be created on-the-fly.<\/li>\n<\/ul>\n<p>The second point above is probably the most important thing to bear in mind. Consider a view containing a text field. The view has a context menu:<\/p>\n<p><code \/><\/p>\n\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n\t\t\tid=\"fm_simplecontextmenulzx_1196731793\"\n\t\t\tclass=\"flashmovie\"\n\t\t\twidth=\"300\"\n\t\t\theight=\"75\">\n\t<param name=\"movie\" value=\"\/blog\/wp-content\/uploads\/2007\/04\/simplecontextmenulzx.swf\" \/>\n\t<!--[if !IE]>-->\n\t<object\ttype=\"application\/x-shockwave-flash\"\n\t\t\tdata=\"\/blog\/wp-content\/uploads\/2007\/04\/simplecontextmenulzx.swf\"\n\t\t\tname=\"fm_simplecontextmenulzx_1196731793\"\n\t\t\twidth=\"300\"\n\t\t\theight=\"75\">\n\t<!--<![endif]-->\n\t\t\n\t<!--[if !IE]>-->\n\t<\/object>\n\t<!--<![endif]-->\n<\/object>\n<p>Notice how if you click on the text field, you don't get a custom option in the context menu, but if you carefully click in the yellow area above, below or to the right of the text, you do see a \"Chop\" option?<\/p>\n<p>The workaround here is to place a transparent view in front of the subviews, that's the full height and width of its parent. If it's not clickable, it will allow <em>left<\/em> clicks to pass through, but right clicks will pass through. Unfortunately, because of <a href=\"http:\/\/www.openlaszlo.org\/jira\/browse\/LPP-3852\">a bug<\/a>, that view can't really be transparent, but instead it needs to have a bgcolor, and a low opacity. You can see the improved effect in the application below:<\/p>\n\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n\t\t\tid=\"fm_bettercontextmenulzx_2135545112\"\n\t\t\tclass=\"flashmovie\"\n\t\t\twidth=\"300\"\n\t\t\theight=\"75\">\n\t<param name=\"movie\" value=\"\/blog\/wp-content\/uploads\/2007\/04\/bettercontextmenulzx.swf\" \/>\n\t<!--[if !IE]>-->\n\t<object\ttype=\"application\/x-shockwave-flash\"\n\t\t\tdata=\"\/blog\/wp-content\/uploads\/2007\/04\/bettercontextmenulzx.swf\"\n\t\t\tname=\"fm_bettercontextmenulzx_2135545112\"\n\t\t\twidth=\"300\"\n\t\t\theight=\"75\">\n\t<!--<![endif]-->\n\t\t\n\t<!--[if !IE]>-->\n\t<\/object>\n\t<!--<![endif]-->\n<\/object>\n<p><a id=\"p20\" href=\"http:\/\/www.antunkarlovac.com\/blog\/wp-content\/uploads\/2007\/04\/rightclick.zip\">Source code for simple and better context menu.<\/a><\/p>\n<p>Finally, remember that the LzContextMenu object will send an <strong>onmenuopen<\/strong> event, when the menu is opened. You can use a delegate to trap this event, and call a method to create all the entries in  a context menu, just before it is displayed.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>OpenLaszlo allows users to define custom context menu (i.e. right-click menu) options throughout your applications. There&#8217;s two classes involved here: LzContextMenu and LzContextMenuItem. The former represents the context menu itself, and the latter represents a single option within it. Some capabilities and guidelines: Stick to Flash Player 8 or DHTML for your runtime, if you &hellip; <a href=\"https:\/\/www.antunkarlovac.com\/blog\/2007\/04\/04\/context-menu-guidelines\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Context Menu Guidelines<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}