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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

In ACL language, how to create a button in a customized toolbar and how to attach a function to the button ?

dgopois
12-Amethyst

In ACL language, how to create a button in a customized toolbar and how to attach a function to the button ?

I have created a toolbar with a button using XUI dialog boxes. The button and the toolbar are displayed successfully but the command associated with the button doesn't work? Can you help me ?

code fragments:

function _init1(win = current_window())
{
if (window_state(win) < 0) {
response("Invalid window $win")
return
}

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

local dirPath=dirname(doc_path(doc));
dirPath=$dirPath . "dialogs\\toolbar_InsertRevisionTags.xml"
dirPath=absolute_file_name($dirPath);

append_dialogs_path(dirPath, 1);

if (!dlgitem_exists(win, 'toolbar_InsertRevisionTags')) {
window_load_component_file(win, 'toolbar_InsertRevisionTags.xml')
}

ret=dlgitem_add_callback(win ,'button_InsertRevisionTags', 'attach_callback');

}

#function 'attach_callback'

function attach_callback(win, dlgitem, event, data, appdata)

response("ok")

}

1 ACCEPTED SOLUTION

Accepted Solutions
pnagai
4-Participant
(To:dgopois)

Do you have a typo? There is no open { associated with function attach_callback() toward the end of your code.

In addition to the strategy you're using, I use this one, too: I attach the command directly to the <button> element in the XUI. For example:

<button command="mypackage::myfunction()" id="mybutton" image="myimg" tiptext="mytiptext">

Then mypackage just has to be sourced before the button is clicked and beep beep pow, it works.

View solution in original post

2 REPLIES 2
pnagai
4-Participant
(To:dgopois)

Do you have a typo? There is no open { associated with function attach_callback() toward the end of your code.

In addition to the strategy you're using, I use this one, too: I attach the command directly to the <button> element in the XUI. For example:

<button command="mypackage::myfunction()" id="mybutton" image="myimg" tiptext="mytiptext">

Then mypackage just has to be sourced before the button is clicked and beep beep pow, it works.

dgopois
12-Amethyst
(To:pnagai)

Thank you for your help.

Ok for the missing character "{". It's just an error when I wrote the discussion.

Top Tags