cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I install a custom toolbar in the Epic editor 5.4?

SOLVED
Level 13

Re: How do I install a custom toolbar in the Epic editor 5.4?

Sorry, it looks like it doesn't like the dashes in the package name. Try replacing with underscores:

 

package my_custom_toolbar;

Level 7

Re: How do I install a custom toolbar in the Epic editor 5.4?

As I mentioned in an edit, you were correct, it didn't like the '-' in the package name. It also didn't like the '/' operator for some reason. So I've kept the code on one line to avoid using that '/' character.

 

Now it runs through the code and reports "Invalid window: -1", which is from my ACL code. However, it doesn't show the toolbar when all is said and done. Or when I load a new document into the editor.

-Giorgio

 

Level 7

Re: How do I install a custom toolbar in the Epic editor 5.4?

Hi Clay,

I read the documentation on the window_add_callback (window, cbtype, callback) function but I still am not clear on how to actually use it. I tried the following code adjustments, please let me know if I am close and where I was mistaken.

 

BTW, my toolbar's ID is "myCustomToolbar" which is in my XUI xml file as you know.

 

package my_custom_toolbar

function init(win = current_window())
{
  if (window_state(win) < 0) {

    # As expected, the following line of code

    # fires when Arbortext is first started.
    response("Invalid window $win");
    return;
  }

  local doc = window_doc(win)
  if (!doc_valid(doc)) {
    response("Invalid document");
    return;
  }

  # Load my custom toolbar on Windows.
  local XUI_file = get_custom_dir() . "\\dialogs\\my-custom-toolbar.xml";
  window_load_component_file(win, XUI_file);
 
  # window_add_callback (window, cbtype, callback)
  ret = window_add_callback (win,'myCustomToolbar',WINDOW_LOAD);
  return win;
}
# Call the above function
init();

 

What is apparently happening is that the above code runs only once, and that's it. Even if I open a document for edit, it doesn't run again. Therefore, it can never reach the loading of my custom toolbar or the callback code. Could you please show me how to use the window_add_callback() function in this case? Also, could you please help me get unstuck from not having my code run more than once?

Your help is greatly appreciated Clay, thanks a bunch.

 

Regards,

- Giorgio

 

 

Level 7

Re: How do I install a custom toolbar in the Epic editor 5.4?

Hi Everyone,

I think I may have the solution for my issue. I wanted to load a custom toolbar when Arbortext is first started but I just couldn't do it. Thanks to Clay, and some information that I found on this site I was able to get it to work as I want. Now the question is ... did I do it properly?

 

Here's my ACL code:

 

------------------------------------------------
package my_custom_toolbar;

# Forward references
function reload_Toolbar(){}#<==I don't know if I really need this?

function init_toolbar(win = current_window())
{
  # Use a window callback to load the toolbar on callback.
  window_add_callback(0,'create','reload_Toolbar');

  return win;
}

 

# Function to actually load the toolbar.
function reload_Toolbar(win)
{
  # Load my custom toolbar on Windows.
  local XUI_file = get_custom_dir() . "\\dialogs\\my-custom-toolbar.xml";

 

  if(win && XUI_file)

  {
    window_load_component_file(win, XUI_file);

  }

  else

  {

    response("An unknown error has occurred while loading the window.");

  }
}

# Call the above function
init_toolbar();

-------------------------------------------------

 

And that's what I have. Clay please provide your input so I don't inadvertently give a bad example here.

Thanks,

Giorgio

 

Level 13

Re: How do I install a custom toolbar in the Epic editor 5.4?

Looks good to me, Giorgio! Nice work putting the pieces together.

Level 7

Re: How do I install a custom toolbar in the Epic editor 5.4?

Thanks Clay!

BTW, can these toolbars be colored with backgroundcolor="#1E90FF" type declarations in the XUI file? I tried it with one of the buttons on my toolbar, the toolbar element, and the window, but nothing worked.

-Giorgio