Detecting the note popup under the mouse?

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Detecting the note popup under the mouse?

Post by stephen.starr » Tue Nov 08, 2016 12:46 am

I am using our own custom right-click context menus and need a way to detect when the user right clicks on a popup. I can detect that they clicked on an annotation by using the code below, but I can't seem to find a way to detect the popup.

int hitTestCode;
_selectedAnnotation = pagesView.GetAnnotFromPt(ref _rightClickViewerLocation, out hitTestCode);

The native right-click menus seem to detect this okay so I know it is possible. Just not sure how.

I am using v318.1 of the editor SDK.

Thank you,
Stephen

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Tue Nov 08, 2016 11:31 am

Hello Stephen,

Are you using the e.beforeShowContextMenu event to reload the default menu?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Tue Nov 08, 2016 5:15 pm

Yes I am.

This allows me to use my own context menus. I then get the annotation at the point of click to change the menu to the annotation specific menu (i.e. add reply, open popup note, etc...).

I can't figure out how to tell that I right-clicked on a popup note though.

Thank you,
Stephen

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Tue Nov 08, 2016 5:27 pm

Hello Stephen,

How about detecting the popup menu by it's ID that you are getting from the event?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Tue Nov 08, 2016 6:03 pm

Alex, thank you. That is exactly what I needed.

Works great and will simplify my existing detection code. I didn't realize that information came through the event.

Thanks again,
Stephen

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: Detecting the note popup under the mouse?

Post by John - Tracker Supp » Tue Nov 08, 2016 6:20 pm

Pleased all is well Stephen :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Tue Nov 08, 2016 6:34 pm

Alex, I noticed that the pencil and the squarecircle event ID's are switched.

If I right-click on a squarecircle annotation I get the pencil event ID, and vice-versa.

This doesn't affect my code, but thought I would pass it along.

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4944
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Detecting the note popup under the mouse?

Post by Paul - Tracker Supp » Tue Nov 08, 2016 7:25 pm

Hi Stephen,

we have found that these were in fact reversed. This is now corrected in the source code and the fix will be available in 319.

Thanks for pointing that out!

Paul
_________________
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Fri Aug 04, 2017 9:33 pm

Hi Alex,

I am using v319 of the editor SDK.

I have one more issue with this. If I right-click on a popup and the active tool is any of the following:

Pencil, Rectangle, FreeText, Comment, Typewriter, or Stamp, I get the menu ID of 2810 which is menu.pagesView.

If I have the hand or line selected, I get 2846 (menu.tool.annot.squareCircle) or 2840 (menu.tool.annot.line). Since it is an annotation menu, I can show that menu in only these 2 cases.

I am seeing that the default Tracker menu's work regardless of the active tool so I am wondering if maybe there is another way to detect this?

Thank you,
Stephen

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Mon Aug 07, 2017 2:56 pm

Hello Stephen,

Can you please make a screenshot of you are meaning by clicking on a popup?
Also, please refrain from the numeric values in your project - the id values will be changed from build to build - you will need to generate them from their string representations each time the project starts for correct work.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Mon Aug 07, 2017 5:15 pm

Thank you Alex. I am not using the numeric values, I just added them for reference to the post.

See attached PNG's for the case where I get the correct menu and the case where I get the wrong menu.

Thank you,
Stephen
Attachments
WrongMenu.PNG
CorrectMenu.PNG

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Tue Aug 08, 2017 2:29 pm

Hello Stephen,

I see what you need now. I will do some experiments and hopefully will find a solution for you.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Tue Aug 08, 2017 5:19 pm

Thank you Alex. Appreciate your help.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Wed Aug 09, 2017 2:05 pm

Hello Stephen,

You can do something like this to detect the popups - they are not in the page annot list by default:

Code: Select all

if (e.nEventID == nIDS[(int)IDS.e_beforeShowContextMenu])
{
	tagPOINT pt;
	pt.x = System.Windows.Forms.Cursor.Position.X;
	pt.y = System.Windows.Forms.Cursor.Position.Y;
	IPXV_PagesView pv = pdfCtl.Doc.ActiveView.PagesView;
	int nH = 0;
	tagPOINT ptRes;
	//Converting screen point to PDFXEdit client point
	pdfCtl.Doc.ActiveView.PagesView.Obj.ScreenPtToClient(pt, out ptRes);
	PXC_Point ptPagePoint;
	int nPage = pdfCtl.Doc.ActiveView.PagesView.Layout.HitTest(ptRes, out ptPagePoint);
	bool bHitTestPopup = false;
	if (nPage >= 0)
	{
		IPXC_Page page = pdfCtl.Doc.CoreDoc.Pages[(uint)nPage];
		uint annotsCount = page.GetAnnotsCount();
		for (uint j = 0; j < annotsCount; j++)
		{
			PDFXEdit.IPXC_Annotation annot = page.GetAnnot(j);
			if (annot.Popup != null)
			{
				PXC_Rect rcPopup = annot.Popup.get_Rect();
				if (((rcPopup.left <= ptPagePoint.x) && (rcPopup.right >= ptPagePoint.x)) &&
					((rcPopup.bottom <= ptPagePoint.y) && (rcPopup.top >= ptPagePoint.y)))
				{
					bHitTestPopup = true;
					break;
				}
			}
		}
	}
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

stephen.starr
User
Posts: 123
Joined: Wed Mar 25, 2015 10:59 pm

Re: Detecting the note popup under the mouse?

Post by stephen.starr » Wed Aug 09, 2017 5:23 pm

Thank you Alex, I will try this out.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4325
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team » Wed Aug 09, 2017 8:33 pm

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply