additional explanation custom event handler

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
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

additional explanation custom event handler

Post by EricAriens » Tue Jun 07, 2016 7:40 am

Hi,

I want to catch the left mouse click. I found some info in the forum Right click menu.
I added the Custom Event handler code to the FullDemo, but I need some additional explanation.

The OnEvent method should fire. When? What is the trigger and can I change the trigger?
What should be done to initialize?

Regards
Eric

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team » Tue Jun 07, 2016 7:50 am

Hello Eric,

The initialization is done here:
https://gist.github.com/Polaringu/648a3 ... er-L52-L59
The OnEvent method will fire every time when ANY event occurs with the given object. Thus you'll need to handle ones you need.
You won't need the HasInvalidPaths method or any annotation search code. This sample was written for some developer for his specific cause. As for the triggers - you can find information about those the PDF specification.

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

EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: additional explanation custom event handler

Post by EricAriens » Tue Jun 07, 2016 8:25 am

Ok this what I want to do.

When a user clicks on a button the cursor should change to the cross (like when you click a tool).
Then when the user clicks on the pdf, on that spot, a textbox should appear with a predefinned text.

Its a stamp the user can create himself. This makes is possible to the user to create his own stamps.
A placeholder can be added to the text and replaced with the date and or time on actual placement.

With the custom handler I can detect the user clicking in the pdf and thus find the click location.
Now I want to change the mouse cursor. Is that possible?

Regards
Eric

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team » Tue Jun 07, 2016 2:10 pm

Hello Eric,

You can change the cursor like this:

Code: Select all

uiInst.SetCursor(uiInst.GetCursorID("cross"));
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mbz
User
Posts: 39
Joined: Wed Jul 13, 2016 2:50 pm

Re: additional explanation custom event handler

Post by mbz » Tue Sep 13, 2016 3:18 pm

Hi folks,

For me "SetCursor" doesn't work. I'm trying to set the cursor like in Alex' expample. Nothing changes.
It doesn't work in my IUIX_ObjImpl. Is there something I should pay attention to?
All I do is just:

Code: Select all

public void OnEvent(IUIX_Obj pSender, IUIX_Event pEvent)
{
    _uiInst.SetCursor(_uiInst.GetCursorID("cross"));
}
Whatever, usually that should work correctly, right?
If so, I do not understand whats wrong.
Maybe you can hep me.

Regards
mbz

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team » Wed Sep 14, 2016 2:15 pm

Hello mbz,

Please try doing this:

Code: Select all

public void OnEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
{
	//If the event is not handled then it will be 
	pEvent.Handled = false;
	//
	if (pEvent.Code == (int)0x200) //WM_MOUSEMOVE
	{
		Parent.uiInst.SetCursor(Parent.uiInst.GetCursorID("cross"));
		pEvent.Handled = true;
	}
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mbz
User
Posts: 39
Joined: Wed Jul 13, 2016 2:50 pm

Re: additional explanation custom event handler

Post by mbz » Fri Sep 16, 2016 6:51 am

Hi Alex,
Unfortunately that doesn't effect anything. Well, there is a subsecond cross everytime the mouse is moved, for sure. But I need that cross until e.g. tool.hand is selected.
Something like:

Code: Select all

public void OnNotify(int nCode, IUIX_Cmd pCmd, IUIX_CmdItem pItem, IUIX_Obj pOwner, uint nNotifyData)
{
     if (!nCode.Equals((int)UIX_CmdNotifyCodes.UIX_CmdNotify_Exec)
          || !pCmd.ID.Equals(inst.Str2ID("cmd.myCustom", false)) return;

     uiInst.SetCursor(uiInst.GetCursorID("cross"));
}
And than the cursor is a cross. Until the handler of any other command - e.g. tool.hand - changes the cross back to the hand (if it is done by the handler. I don't know it, because there is no documentation about it).
What does uiInst.SetCursor exactly do?
http://sdkhelp.tracker-software.com/vie ... _SetCursor <-- that description doesn't help me neither. I don't know whether that's the usual behavior; a subsecond cross.
I need to set the cross permanently.

Regards,
mbz

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team » Fri Sep 16, 2016 9:31 am

Hello mbz,

I've only shown you how to properly change a cursor to another one. All of the other logic must be implemented from your side. All I can do is advice you how to do this.
First what you need to do is to implement the custom event handler for the Pages View (what you already have, from what I see). There, you will need to have some kind of flags that will indicate whether the cursor needs to be manually modified. The thing is that the SetCursor method will change the cursor only until some other handler changes it. Thus when you change the cursor on the WM_MOUSEMOVE event of the Pages View's custom event listener then you assure that all of the other cursors will be overwritten.
When you are using the custom command handler for some tools etc, in the OnNotify method you will need to change the Pages View's Custom Event Handler's flags to your needs so that the cursor will or will not be changed manually.

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

Post Reply