Pages: 1
Print
Author Topic: Insert Table functionality  (Read 1928 times)
pooh2583
Member

Posts: 47


« on: March 11, 2013, 04:33:31 AM »

Hi,

In xmetal there is a functionality of inserting a table into an xml document,which is present in built in xmetal,  but icon for insert table is enabled only when it has (selection location)a valid location for adding a table in the location otherwise it is disabled.

I wnt to have a functionality where clicking on insert table icon(which will be enebled all the time) it will find a proper location to insert a table and then the small window apears which asks to enter no. of rows and columns and header in the table.

How to achieve this functionality?

please reply

Regards
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: March 11, 2013, 11:26:34 AM »

I think you will need to create a macro and hook it up to a button or menu item.

The logic in the macro will depend on exactly what you want to accomplish but at minimum you would probably call FindInsertLocation() and you'll probably want to check if it succeeded. If it succeeded then you can have it launch Table > Insert Table, or you could have it launch your own custom insert table dialog.

To launch the built-in Insert Table function, and assuming the Table menu hasn't been modified, you could call it like this:

// XMetaL Script Language JSCRIPT:
var mainMenu = Application.CommandBars.item("Menu bar");
var tableMenu= mainMenu.Controls.item("Table");
var insertTableCmd = tableMenu.Controls.item(1);
insertTableCmd.Execute();


To launch it from the Table toolbar, and assuming the Table toolbar hasn't been modified, you could call it like this:

// XMetaL Script Language JSCRIPT:
var tableToolbar = Application.CommandBars.item("Table");
var insertTableCmd = tableToolbar.Controls.item(1);
insertTableCmd.Execute();


Those are just quick examples. To be robust (some users do change menus and toolbars around -- unless you have disabled that feature) you might implement code that sets the "insertTableCmd" based on looking for the actual menu item's title (probably "Insert &Table...").

For info on launching your own custom dialog (XFT) see CreateFormDlg() in the Programmers Guide.
« Last Edit: March 11, 2013, 12:23:49 PM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us