override context menu and add new menuItem
override context menu and add new menuItem
if(Plugins.HookMethod(this,"ContrApptSheet2_MouseDown_start",ContrApptSingle.ClickedAptNum,e))
{
return;
}
with this hookmethod i want to add new menuitem in menuApt contextmenu on RightClick of ContrApptSheet2.I was unable to ovveride contextMenu and add new one item in existing menuApt contextMenu.
Thanks,
Ashok patel
{
return;
}
with this hookmethod i want to add new menuitem in menuApt contextmenu on RightClick of ContrApptSheet2.I was unable to ovveride contextMenu and add new one item in existing menuApt contextMenu.
Thanks,
Ashok patel
Re: override context menu and add new menuItem
So I assume you copied the code from ContrApptSheet2_MouseDown into the plugin and are just adding in a small bit of code to add a menu item correct?
I don't see how that would fail if you made you code similarly to the way the existing code looks.
I don't see how that would fail if you made you code similarly to the way the existing code looks.
Re: override context menu and add new menuItem
You shouldn't override it, you need to use the object "Sender" and loop through all it's controls and find "menuApt" and then add to it's MenuItems. Know that your new menu item will get wiped out when the user clicks the Appts module button so you'll probably need to add code that first checks to see if your custom menu item is present and add it only when it is not present.
The best thing about a boolean is even if you are wrong, you are only off by a bit.
Jason Salmon
Open Dental Software
http://www.opendental.com
Jason Salmon
Open Dental Software
http://www.opendental.com
Re: override context menu and add new menuItem
I am unable to find control for 'menuApt' only using the object "Sender" and I want add new new menu item in existing and don't want to wiped out existing menuItem. Please help me with this.
Thanks,
Ashok Patel
Thanks,
Ashok Patel
Re: override context menu and add new menuItem
The first option you could pursue is to utilize the hookmethod you mentioned to add your own behavior for the ContrApptSheet2_MouseDown method. To access menuApt in your code would look like this:
Another option is that we could add a hookaddcode for you right before the menuApt is show:
Code: Select all
public override bool HookMethod(object sender,string hookName,params object[] parameters) {//required method
switch(hookName){
case "ContrApptSheet2_MouseDown_start":
ContrAppt contrAppt=(OpenDental.ContrChart)sender;
ContextMenu menuApt=(TabControl)contrAppt.Controls.Find("menuApt",true)[0];
//Now add any items that you want to menuApt
return true;//You might want to return false here so that the real ContrApptSheet2_MouseDown still runs.
default:
return false;//this plugin does not implement the particular hook passed in.
}
}
Code: Select all
//Texting
menuApt.MenuItems.Add("-");
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Text Div";
menuApt.MenuItems.Add(Lan.g(this,"Send Text"),menuApt_Click);
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Send Text";
if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
}
menuApt.MenuItems.Add(Lan.g(this,"Send Confirmation Text"),menuApt_Click);
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Send Confirmation Text";
if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
}
//menuApt.MenuItems.Add(Lan.g(this,"Send Reminder Text"),menuApt_Click);
//if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
// menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
//}
Plugins.HookAddCode(this,"ContrApptSheet2_MouseDown_menuApt_right_click");
menuApt.Show(ContrApptSheet2,new Point(e.X,e.Y));
Re: override context menu and add new menuItem
Please do help add - Plugins.HookAddCode(this,"ContrApptSheet2_MouseDown_menuApt_right_click");. Believe will also need menuApt object to be public to access it.
Another option is that we could add a hookaddcode for you right before the menuApt is show:
[/quote]
Another option is that we could add a hookaddcode for you right before the menuApt is show:
Code: Select all
//Texting
menuApt.MenuItems.Add("-");
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Text Div";
menuApt.MenuItems.Add(Lan.g(this,"Send Text"),menuApt_Click);
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Send Text";
if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
}
menuApt.MenuItems.Add(Lan.g(this,"Send Confirmation Text"),menuApt_Click);
menuApt.MenuItems[menuApt.MenuItems.Count-1].Name="Send Confirmation Text";
if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
}
//menuApt.MenuItems.Add(Lan.g(this,"Send Reminder Text"),menuApt_Click);
//if(!SmsPhones.IsIntegratedTextingEnabled() && !Programs.IsEnabled(ProgramName.CallFire)) {
// menuApt.MenuItems[menuApt.MenuItems.Count-1].Enabled=false;
//}
Plugins.HookAddCode(this,"ContrApptSheet2_MouseDown_menuApt_right_click");
menuApt.Show(ContrApptSheet2,new Point(e.X,e.Y));
Re: override context menu and add new menuItem
Ashok,
I have added this hook for you. I gave it the name "ContrAppt.MouseDownAppointment_menuApt_right_click" because this section of code has changed since when I originally suggested this hook. You shouldn't need menuApt to be public. You can access it like this:
I backported the hook to 18.1.29.
I have added this hook for you. I gave it the name "ContrAppt.MouseDownAppointment_menuApt_right_click" because this section of code has changed since when I originally suggested this hook. You shouldn't need menuApt to be public. You can access it like this:
Code: Select all
OpenDental.ContrAppt contrAppt=(OpenDental.ContrAppt)sender;
ContextMenu menuApt=(ContextMenu)contrAppt.Controls.Find("menuApt",true)[0];
Re: override context menu and add new menuItem
Hi Chris,cmcgehee wrote:Ashok,
I have added this hook for you. I gave it the name "ContrAppt.MouseDownAppointment_menuApt_right_click" because this section of code has changed since when I originally suggested this hook. You shouldn't need menuApt to be public. You can access it like this:I backported the hook to 18.1.29.Code: Select all
OpenDental.ContrAppt contrAppt=(OpenDental.ContrAppt)sender; ContextMenu menuApt=(ContextMenu)contrAppt.Controls.Find("menuApt",true)[0];
Thanks for changes. For some reason I am not able to find menuApt object via code below.
Code: Select all
ContextMenu menuApt=(ContextMenu)contrAppt.Controls.Find("menuApt",true)[0];
Code: Select all
Plugins.HookAddCode(this,"ContrAppt.MouseDownAppointment_menuApt_right_click", menuApt);
Re: override context menu and add new menuItem
Can you share the snippet of code where you're trying to find the menuApt object via Controls.Find? Maybe I can spot why it's not working.
Re: override context menu and add new menuItem
cmcgehee wrote:Can you share the snippet of code where you're trying to find the menuApt object via Controls.Find? Maybe I can spot why it's not working.
Code: Select all
ContextMenu menuApt=(ContextMenu)contrAppt.Controls.Find("menuApt",true)[0];
Re: override context menu and add new menuItem
Can you share the whole method where you have this line of code?
Re: override context menu and add new menuItem
I was wrong, the object "Sender" doesn't own menuApt. Technically menuApt gets dynamically associated to the ContrApptSheet2 control in a line after the hook method. Chris can simply pass the control into the hook method.jsalmon wrote:You shouldn't override it, you need to use the object "Sender" and loop through all it's controls and find "menuApt" and then add to it's MenuItems. Know that your new menu item will get wiped out when the user clicks the Appts module button so you'll probably need to add code that first checks to see if your custom menu item is present and add it only when it is not present.
The best thing about a boolean is even if you are wrong, you are only off by a bit.
Jason Salmon
Open Dental Software
http://www.opendental.com
Jason Salmon
Open Dental Software
http://www.opendental.com
Re: override context menu and add new menuItem
""Technically menuApt gets dynamically associated to the ContrApptSheet2 control in a line after the hook method
Thanks Jason for clarification.
This will be wonderful.Chris can simply pass the control into the hook method
Thanks guys and please do update which version its gets ported back.
Re: override context menu and add new menuItem
OD Team,
Any updates on this.
Thanks,
Ashok
Any updates on this.
Thanks,
Ashok
Re: override context menu and add new menuItem
I just now committed the change to the hook. It will be available in 18.1.35.0. Sorry about giving you faulty advice before.
Re: override context menu and add new menuItem
cmcgehee wrote:I just now committed the change to the hook. It will be available in 18.1.35.0. Sorry about giving you faulty advice before.
Thank You!