Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
104
Ultratoolbarsmanager: Tool click code-base
posted

HI at all,

How can I fire the click event of a tool from the Ultratoolbar manually by code?
I read something about a "perform default action" thing somewhere, but can't remember.
I thought about one of the following ways:
Toolbarsmanager.tools("button").performaction ... or ... eventmanager.event("click").activate()
OR OTHERWISE Toolbarsmanager_Toolsclick(me, [set eventargs to buttontool])

But I don't find any way to do this. 

On the second way I don't know how to set/create the eventargs manually to raise the toolsclick event properly.

Have anybody a solution for this?

Thanks

Parents
No Data
Reply
  • 5
    Suggested Answer
    Offline posted

    Vince McDonald is totally right about the very best practice to design the code to be decouple from the UI controls. 

    However, if you really want to hack the system to raise the event without having to redesign your application in cases where you don't have the capability to change it, here is a little workaround to do the job:

    toolbarsManager.GetType().InvokeMember("FireEvent",
    BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic, null,
    toolbarsManager, new object[] { ToolbarEventIds.ToolClick,
    new ToolClickEventArgs(button, null) });

    where toolbarsManager is your ToolBar and button is the button you want to trigger the click event.

    I have to say that I currently use this hack because the toolbar is filled with a component that inject objects inside each ButtonTool and listen the ToolClick to execute action linked with the objects injected inside ButtonTool and for this reason, I'm not able to grab the Action Executer to change the design.

Children
No Data