No i haven't put my own code against this button but you can easily do this.
The toolbar button event triggers a menuAction event using an id number, if in the menuAction event for the form you trap when this id is sent in you can call your custom method to execute.
The following is an example:
In the forms open method the following code exists:
Code:
method open(var eventInfo Event)
if eventInfo.isPreFilter() then
;// This code executes for each object on the form
else
;// This code executes only for the form
tb.create("Test")
tb.addButton(ToolbarMiscCluster, ToolbarButtonPush,
UserMenu + 1, BitmapAddTable, "Custom")
tb.show()
endIf
endMethod
Within the form I have a custom method called showMyMessage which contains the following code:
Code:
method showMyMessage()
msgInfo("showMyMessage",
"This is a custom method called from a toolbar button")
endMethod
Within the menuAction method I trap the code and execute my own method/code as follows:
Code:
method menuAction(var eventInfo MenuEvent)
var
siEvent SmallInt
endVar
siEvent = eventInfo.id() ; Get the Event ID into a variable
if eventInfo.isPreFilter() then
;// This code executes for each object on the form
else
;// This code executes only for the form
; Menu/Toolbar Event Custom Processing
switch
case siEvent = UserMenu + 1 :
showMyMessage()
otherWise :
doDefault
endSwitch
endIf
endMethod
If you want to add more custom methods to a toolbar then the trick is where you stated MenuWorkingDir you replace this with a constant value, for custom events this should always be UserMenu + <your number> and then trap for this value in the menuAction method of the form.
Hope this helps
Regards,
Jonathan