IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Enabling custom buttons Options · View
KeithM
Posted: Monday, March 10, 2008 1:21:21 PM
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
KeithM
Posted: Monday, March 10, 2008 2:29:37 PM
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.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.