Detecting the note popup under the mouse?

PDF-XChange Editor SDK for Developers

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

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 »

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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

Hello Stephen,

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

Cheers,
Alex
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 »

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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

Hello Stephen,

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

Cheers,
Alex
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 »

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
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Detecting the note popup under the mouse?

Post by John - Tracker Supp »

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 »

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: 6829
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 »

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
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 »

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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

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
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 »

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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

Hello Stephen,

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

Cheers,
Alex
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 »

Thank you Alex. Appreciate your help.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

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
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 »

Thank you Alex, I will try this out.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Detecting the note popup under the mouse?

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply