LaunchToolbarButton being called multiple times

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
dcrider
Posts: 67
Joined: Sun Sep 29, 2019 11:03 am
Contact:

LaunchToolbarButton being called multiple times

Post by dcrider » Fri Apr 10, 2020 11:55 am

I have a plugin overriding LaunchToolbarButton(long patNum), however I might be using it incorrectly.

If a user has switched patients at all before clicking my button, all previously selected patNums are passed in one at a time. I have logic checking for certain criteria that fails for some patients and not for others. When multiple patNums are passed in, if even one fails my plugin exists with a message to the user that the patient didn't meet the criteria, even if the currently selected patient fulfills that criteria.

Is there something I'm missing here? Here's the code (the criteria check happens when the CurrentPatient value is changed and OurPatient is instantiated in the constructor of FormMain)

Code: Select all

public override void LaunchToolbarButton(long patNum)
{
     if (DataCheck.TableExists("rd_location"))
     {
           FormMain formMain = new FormMain();
          if (patNum != 0 && formMain.OurPatient!= null)
          {
              formMain.OurPatient.CurrentPatient = Patients.GetPat(patNum);
          }
     }
}

joes
Posts: 239
Joined: Tue Aug 13, 2019 12:41 pm

Re: LaunchToolbarButton being called multiple times

Post by joes » Fri Apr 10, 2020 1:47 pm

Our engineer who typically answers questions of this kind is out today. I'll make sure that he is aware of your post. I hope to have a response for you on Monday.
Joe Sullivan
Open Dental Software
http://www.opendental.com

User avatar
dcrider
Posts: 67
Joined: Sun Sep 29, 2019 11:03 am
Contact:

Re: LaunchToolbarButton being called multiple times

Post by dcrider » Fri Apr 10, 2020 1:53 pm

Thank you for the update.

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: LaunchToolbarButton being called multiple times

Post by cmcgehee » Mon Apr 13, 2020 8:11 am

dcrider,

I'm not seeing a mechanism that would cause LaunchToolbarButton to be called more than once. If you put a breakpoint at

Code: Select all

if (DataCheck.TableExists("rd_location"))
does it get hit more than once with different patNums?
Chris McGehee
Open Dental Software
http://www.opendental.com

User avatar
dcrider
Posts: 67
Joined: Sun Sep 29, 2019 11:03 am
Contact:

Re: LaunchToolbarButton being called multiple times

Post by dcrider » Mon Apr 13, 2020 8:59 am

Here's the issue. When I select a patient, then click my button and interact with it in any way (i.e. fill in a textbox or click a button), then close my form, select a different patient and click my button, I get the patNum of the previously selected patient, then the currently selected patient. And it's cumulative, so if I do that with 10 patients, I get all previous ones every time.

User avatar
dcrider
Posts: 67
Joined: Sun Sep 29, 2019 11:03 am
Contact:

Re: LaunchToolbarButton being called multiple times

Post by dcrider » Mon Apr 13, 2020 11:10 am

It must be something with my code that's keeping the last patient; the patNum passed in is only ever the currently selected patient, as expected

Post Reply