Community
Showing results for 
Search instead for 
Do you mean 
Reply

How does Custom Button A tell Plugin Button B that it's been clicked?

Tuned Listener
Posts: 35
Country: Australia

How does Custom Button A tell Plugin Button B that it's been clicked?

Custom Button A loading from Tools directory.
Button B on Panel in CustomSubEntity loading from Plugins directory.
Button A is clicked.
How do we tell Button B that button A has been clicked?
Reece harper

Act! Certified Consultant Australia
http://www.databasepartners.com.au
Nickel Super Contributor
Posts: 441
Country: UK

Re: How does Custom Button A tell Plugin Button B that it's been clicked?

Not sure what you are trying to achieve, maybe you could set a flag somewhere or did you want to just call the button' click event?  Maybe something like this?

 

Private Clicked As Boolean Private Sub Menu_A_Click(ByVal Text As String) 'menu item a clicked 'here we can call a button or set a flag Button_B_Click(Me, Nothing) Clicked = True End Sub Private Sub Button_B_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonB.Click 'check the flag or do other stuff here If Clicked Then 'do somthing End If End Sub

 

Tom

Tuned Listener
Posts: 35
Country: Australia

Re: How does Custom Button A tell Plugin Button B that it's been clicked?

One button ( Button A ) sits on the Contact form. It was loaded as a Custom Control from a dll in the Tools folder. The other button ( Button B ) is the Add button for a Custom subentity in the tab panel which was loaded from a dll in the Plugins folder. These two control have no common variables. It seems Button A must send a message and Button B must subscribe to it.
Reece harper

Act! Certified Consultant Australia
http://www.databasepartners.com.au
Employee
Posts: 236
Country: USA

Re: How does Custom Button A tell Plugin Button B that it's been clicked?

[ Edited ]

There's a couple of ways to do this.  Probably the most straight forward is to reference your plugin dll in your tool dll, or use a common dll, and to expose a public singleton type with anything you want to share.  The plugin can create an instance of that new type (the singleton), and expose it through a property, such that anyone getting the instance would get the same instance.  The button click handler in your plugin should fire the event on the singleton.  

 

Here's a rough (un-compiled) sample of what that single type could look like (just need to add your event to the type):

 

public class Singleton

{

  private static Singleton instance;

  private Singleton(){} // make sure we don't get a default .ctor

  public Static Instance

  {

    get

    {

    if ( instance == null )

      instance = new Singleton(); 

    return instance;

    }

  } 

 

Now as long as you can reference the type, you can access the same instance via: Singleton.Instance. Note that the singleton can be the plugin itself, or whatever makes sense for you to share with any of your other add-ons / tools. 

 

As a side note, if you reference Act.UI.dll, and need to get the running application (ACT!) outside of a plugin, such as in a tool, you can access the ACT! singleton, or ActApplication.Instance (same pattern). 

Message Edited by Xavier on 09-08-2008 11:50 AM