thrash4life
11-03-2006, 09:31 AM
I am currently developing with 3.3.3. How can I leverage the context menu (Cut, Copy Paste, Clear) that is available over a <text selectable="true" /> in an instance where the text has a href / hyperlink on it. The solution has to be cross platform (I saw the other threads referencing the Windows notepad). In consideration that it may not be possible to leverage the context menu or that I could leverage it but I won't achieve the desired results (ex: the context menu will only enable copying the link title and not the link as well nor copying the link by itself), I created my own context menu for my customized <text> class. Could one of y'all hotshots help me "fill in the blanks" with how to create a handler that will copy the link (not just the title)? This customized <text> class is fed via XML where it takes a link title string and a link ref string to create the text link. I specify the <text>'s datapath when I instantiate it on the canvas. Many thanks in advance :) and perhaps someone could leverage this code if s/he is having problems creating a text link from a similar data source.
<class name='textLink' extends='text'>
<attribute name="width" value="${parent.width}" />
<attribute name="multiline" value="true" />
<attribute name="fgcolor" value="#227" />
<attribute name="selectable" value="true" />
<attribute name="onclick" value="LzBrowser.loadURL(href, '_blank')" />
<attribute name="onmouseover" value="this.setText( '<u>' + this.text + '</u>' )" />
<attribute name="onmouseout" value="this.setText(this.defText)" />
<attribute name="text" value="$path{'./link_title/text()'}" />
<attribute name="href" value="$path{'./link_ref/text()'}" />
<attribute name="defText" value="$path{'./link_title/text()'}" />
<method event="oninit" >
var linkContextMenu = new LzContextMenu();
var copyLinkBoth = linkContextMenu.makeMenuItem('Copy Entire Link', new LzDelegate(this, "handlerightclick1"));
var copyLinkLocation = linkContextMenu.makeMenuItem('Copy Link Location', new LzDelegate(this, "handlerightclick2"));
var copyLinkTitle = linkContextMenu.makeMenuItem('Copy Link Title', new LzDelegate(this,
"handlerightclick3"));
linkContextMenu.addItem(copyLinkBoth);
linkContextMenu.addItem(copyLinkLocation);
linkContextMenu.addItem(copyLinkTitle);
linkContextMenu.hideBuiltInItems();
this.setContextMenu(linkContextMenu);
</method>
</class>
<class name='textLink' extends='text'>
<attribute name="width" value="${parent.width}" />
<attribute name="multiline" value="true" />
<attribute name="fgcolor" value="#227" />
<attribute name="selectable" value="true" />
<attribute name="onclick" value="LzBrowser.loadURL(href, '_blank')" />
<attribute name="onmouseover" value="this.setText( '<u>' + this.text + '</u>' )" />
<attribute name="onmouseout" value="this.setText(this.defText)" />
<attribute name="text" value="$path{'./link_title/text()'}" />
<attribute name="href" value="$path{'./link_ref/text()'}" />
<attribute name="defText" value="$path{'./link_title/text()'}" />
<method event="oninit" >
var linkContextMenu = new LzContextMenu();
var copyLinkBoth = linkContextMenu.makeMenuItem('Copy Entire Link', new LzDelegate(this, "handlerightclick1"));
var copyLinkLocation = linkContextMenu.makeMenuItem('Copy Link Location', new LzDelegate(this, "handlerightclick2"));
var copyLinkTitle = linkContextMenu.makeMenuItem('Copy Link Title', new LzDelegate(this,
"handlerightclick3"));
linkContextMenu.addItem(copyLinkBoth);
linkContextMenu.addItem(copyLinkLocation);
linkContextMenu.addItem(copyLinkTitle);
linkContextMenu.hideBuiltInItems();
this.setContextMenu(linkContextMenu);
</method>
</class>