Page 1 of 1

additional explanation custom event handler

Posted: Tue Jun 07, 2016 7:40 am
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

Re: additional explanation custom event handler

Posted: Tue Jun 07, 2016 7:50 am
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

Re: additional explanation custom event handler

Posted: Tue Jun 07, 2016 8:25 am
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

Re: additional explanation custom event handler

Posted: Tue Jun 07, 2016 2:10 pm
by Sasha - Tracker Dev Team
Hello Eric,

You can change the cursor like this:

Code: Select all

uiInst.SetCursor(uiInst.GetCursorID("cross"));
Cheers,
Alex

Re: additional explanation custom event handler

Posted: Tue Sep 13, 2016 3:18 pm
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

Re: additional explanation custom event handler

Posted: Wed Sep 14, 2016 2:15 pm
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

Re: additional explanation custom event handler

Posted: Fri Sep 16, 2016 6:51 am
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

Re: additional explanation custom event handler

Posted: Fri Sep 16, 2016 9:31 am
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