Rank: Member
Joined: 12/6/2007 Posts: 19 Location: Whitby, ON Canada
|
Hello,
Is there a command to enable a custom button? I'm new to Javascript and I'm trying to create a button that toggles the entry helpers, but I only get a disabled button that cannot be clicked.
Here is the javascript code I use to create the button:
var ToolBarRow = objPlugIn.ToolbarRows.Item(1); var Buttons = ToolBarRow.Buttons; Buttons.NewCustomButton(25,'MyFunction','Toggles the entry helper panes', '/i/menu/pobcol_16x16.bmp'); objPlugIn.ReloadToolbars();
And here is the code in the remapped OnDocEditCommand handler:
if(objPlugIn.event.type == "command") { if(objPlugIn.event.srcElement.Name == "MyFunction") alert("You pressed my custom button!"); }
// event.type is set to "update" if the button state must be set if(objPlugIn.event.type == "update") { if(objPlugIn.event.srcElement.Name == "MyFunction") { // we enable the button if only one element is selected if(objPlugIn.CurrentSelection.Start.IsSameNode(objPlugIn.CurrentSelection.End)) objPlugIn.event.returnValue = 1; else objPlugIn.event.returnValue = 0;
objPlugIn.event.cancelBubble = true; } }
I don't actually see where the button is turned on or off.
Thanks in advance for any help. Keith
|
Rank: Member
Joined: 12/6/2007 Posts: 19 Location: Whitby, ON Canada
|
Ok, someone I work with figured it out.
Apparantly the attachCallBack method should come before you build the button.
|