General XMetaL Discussion
Joco73 February 17, 2009 at 1:11 pm
Set align and valign attributes in xmax.February 17, 2009 at 1:11 pmParticipants 2Replies 3Last Activity 13 years, 9 months ago
I am using XMetaL XMAX 5.0 (188.8.131.52) and want by pressing custom buttons in toolbar (buttons and button click logic is done) set the attributes align and/or valign to currently selected cells in table (those with a thick black border around).
How can I get this to work, I have gotten examples where you should store start/end selection in diffrent range objects and then move around changing what i want to change. But I do not understand how I do this, do anyone have workin code examples for similar things.
ex. of xml:
This text is aligned right
This text is valigned bottom
/Jonathanmag3737 February 17, 2009 at 5:13 pm
Reply to: Set align and valign attributes in xmax.February 17, 2009 at 5:13 pm
This is a slightly challenging scripting problem which I'll address separately (unless Derek or someone else beats me to it), but it is important to clarify a little terminology:
XMAX does not have any menus or toolbars. It is a control or widget which can be embedded in any ActiveX-compatible “host application” to allow XML editing. The host application (often a web page) is what provides menus, toolbars, or any other kinds of user interface. The developer of the host application writes script that runs in that application and uses the XMetaL APIs to tell the XMAX control what to do with the XML document that is currently open in the control.
So to address your question more directly, there are two “parts” to what you need to do. One part is adding buttons or other UI to your host application. It is up to you to know how to do that. The other part is the potentially helpful XMetaL script APIs, and I (or someone) will try to help with that.Joco73 February 17, 2009 at 5:53 pm
Reply to: Set align and valign attributes in xmax.February 17, 2009 at 5:53 pm
Thanxs for replying,
I don't get the API to do what i want. If I in my function call:
Then the cell that i stand in or the first cell in a selection get the attribute. What I want to do is to iterate through all of the cells in the selection and do the same thing.
Looking forward for some examples from you or Derek.
/Jonathanmag3737 February 19, 2009 at 2:00 am
Reply to: Set align and valign attributes in xmax.February 19, 2009 at 2:00 am
It seems this is a more challenging problem than I thought. (I had my suspicions, which is why I hedged in the first place.) The problem is that, internally, XMetaL treats selections inside tables a little bit differently than selections anywhere in a document. Unfortunately this has a side effect that some of the XMetaL APIs return unexpected results when your selection is, say, a sequence of table rows or cells. (This is true both for CALS tables such as the example by Joco73, and for HTML tables which are also supported by XMetaL.)
With non-table elements, it is possible to write scripts that iterate over a selected range of nodes, using APIs such as Range.Contains, Range.Collapse, and the Range comparison APIs. Basically you would set a Range variable at the beginning of the user's selection, and another one at the end, and use those in the loop-testing conditions as you move another Range across and set your attributes (or whatever).
But it is precisely those Range APIs that work differently when the selection is within a table. The only way we can think to accomplish something like this would be to provide some sort of artificial mechanism for your script to know how many nodes to process. Imagine prompting the user “How many cells would you like me to process?” and then use the current selected cell as a starting point. Or, for another example, provide macros that are designed to work on all the cells in a single row, column, or table. (Use the Range.Move*** APIs to do the moving around.)
- You must be logged in to reply to this topic.