additional explanation custom event handler

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

additional explanation custom event handler

Post by EricAriens »

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team »

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

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team »

Hello Eric,

You can change the cursor like this:

Code: Select all

uiInst.SetCursor(uiInst.GetCursorID("cross"));
Cheers,
Alex
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 »

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

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team »

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

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?
https://sdkhelp.pdf-xchange.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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: additional explanation custom event handler

Post by Sasha - Tracker Dev Team »

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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply