Skip to main content
1-Visitor
April 29, 2013
Question

Mapping toolbar buttons

  • April 29, 2013
  • 5 replies
  • 1142 views

I am using version 5.3. I want to remap a toolbar button to a custom function. In the help, it states I can map a toobar item (such as Toolbar_Print) in Unix only. How do I accomplish the same thing in Windows? Thanks in advance.

    5 replies

    18-Opal
    April 29, 2013
    Hi John--



    You will need to know the alias called by the button you're interested
    in, and then you can "hijack" it by redefining that alias to execute
    your own code instead of the stock code. For example, let's say you want
    to hijack the File Open button. If you look at the contents of
    $ARBORTEXT/lib/dialogs/editwindow.xml, you will find this inside:



    <toolbar id="toolbar1" name="&amp;ToolbarEdit;" x="0" y="0">

    ....

    <button command="FileOpen" id="Toolbar_Open" image="imageOpen"&lt;br"/>
    statustext="&EditWindow_StatusTextOpen;"

    tiptext="&EditWindow_TooltipOpen;"></button>

    ....



    The command attribute is the thing you're interested in. To change what
    this does, you can use the alias command in your startup ACL file to
    make it do what you want, instead of what it does out of the box. For
    example:



    alias FileOpen { response("This is my custom version of
    file open"); }



    Note that using this approach will also change the function of
    corresponding menu items. In this example, it will change not only the
    toolbar button behavior, but also the behavior of the File->Open menu
    item.



    If you want to only affect the toolbar button, but leave the
    corresponding menu item alone, you will probably need to use
    dlgitem_set() to specify your code as the callback for the item,
    something like this:




    dlgitem_set(current_window(),"Toolbar_Open","callbacks","mypkg::myOpen")
    ;



    where mypkg::myOpen() is a function you have defined to do what you
    want, and the dlgitem_set() call appears in your editinit ACL.



    --Clay



    Clay Helberg

    Senior Consultant



    TerraXML

    1380 Forest Park Circle, Suite 100

    Lafayette, CO 80027
    18-Opal
    April 29, 2013
    A qualification: this is based on version 6.0, there may be (hopefully)
    minor modifications needed for 5.3. (Sorry, I don't have 5.3 installed
    to test against.)



    --Clay



    Clay Helberg

    Senior Consultant



    TerraXML

    1380 Forest Park Circle, Suite 100

    Lafayette, CO 80027
    jbaklayan1-VisitorAuthor
    1-Visitor
    April 29, 2013

    Thanks Clay that worked. On a side note, is there a way to create a custom toolbar item and define your own function. Currently I am having to "steal" a toolbar function from another item I am not using and redefining it. Ideally I would like to do the following:


    <toolbar id="toolbar1" name="&amp;ToolbarEdit;" x="0" y="0">

    ....

    <button command="ACLCustomFunction" id="Toolbar_NewItem" image="imageNewItem"&lt;br"/>statustext="New Item"
    tiptext="New Item"></button>


    If I try and do the above it doesn't know about ACLCustomFunction.


    Thanks again.

    18-Opal
    April 29, 2013
    Hi John--



    The normal way to do this would be to make a custom copy of
    editwindow.xml, place it in $APTCUSTOM/dialogs, and make your changes
    there.



    If you add your sample code, it should work OK, as long as you do define
    a function called ACLCustomFunction(). Note that you will need to make
    sure the function is defined before the window loads, i.e. in your init
    ACL file.



    Note that you'll also need to define the image for the new button at the
    top of the editwindow.xml file in the <imagegroup> section. The default
    button images are defined as regions within one big graphic file via
    <imagelist>. To add an extra one that's separate, use something like
    1-Visitor
    April 30, 2013

    Hi John,


    If you go the $APTCUSTOM/dialogs/editwindow.xml route, not only can you remap toolbar buttons you can add your own custom toolbars by adding new <imagelist> and <toolbar> elements to editwindow.xml.


    Create and reference the custom image file and buttons in the new <imagelist> element:


    <imagelist path="ToolbarMyCustom.bmp" imagewidth="16">
    <image id="imageCustom1"/>
    <image id="imageCustom2"/>
    ...
    </imagelist>


    BTW, imagewidth can be larger than 16 for large buttons.


    Create and reference the custom command buttons in the new <toolbar> element:


    <toolbar dock="none" id="toolbarMyCustom" name="My" custom&quot;=" withdraw="true" x="0"&lt;br"/>y="130">
    <button id="Toolbar_Custom1" statustext="Custom1" status&quot;=" tiptext="Custom1" tip&quot;=" image="imageCustom1" command="MyCustom1Function1.acl"></button>
    <separator/>
    <button id="Toolbar_Custom2" statustext="Custom2" status&quot;=" tiptext="Custom2" tip&quot;=" image="imageCustom2" command="MyCustom1Function2.acl"></button>
    ...
    </toolbar>


    Here's the function I use to show/hide custom toolbars:


    function show_hide_custom_toolbar(tb) {
    # custom toolbar (tb) must be defined in APTCUSTOM/dialogs/editwindow.xml
    # initial setting WITHDRAW=1


    local x=dlgitem_get(current_window(),tb,'WITHDRAW');
    if (x==1) {
    dlgitem_set(current_window(),tb,'WITHDRAW','0');
    dlgitem_set(current_window(),tb,'VISIBLE','1');
    return;
    }


    local a=dlgitem_get(current_window(),tb,'VISIBLE');
    if (a==0) {
    dlgitem_set(current_window(),tb,'VISIBLE','1');
    }else if (a==1) {
    dlgitem_set(current_window(),tb,'VISIBLE','0');
    }


    }


    Lou Argyres
    CEB.com
    Oakland, CA