Add link action for GOTOR  SOLVED

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
zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Add link action for GOTOR

Post by zarkogajic » Mon Sep 09, 2019 3:29 pm

Hi devs,

Say I'm interested only in (creation of) goto / gotor links.

Having the link tool active, dragging a rectangle OR having the text selection tool active and selecting "add goto link" will bring this dialog "Browse for Link Target":
image.png
How do I go about hiding the "Advanced..." button?

Or, renaming the "Advanced..." button to "Another document" (example) and then directly initiating the "GOTOR" action:
image.png
image.png (45.88 KiB) Viewed 1391 times
That is:
image.png
image.png (48.62 KiB) Viewed 1391 times

So, something like

PXV_Control1.Inst.ExecUICmd('cmd.addLink.goto', nil);

or

PXV_Control1.Inst.ExecUICmd('cmd.addLink.launch', nil);

But for GOTOR.

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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Tue Sep 10, 2019 6:58 am

Hello zarkogajic,

Here's the topic that would prove useful:
viewtopic.php?f=66&t=30597&p=122214&hil ... og#p122214
After you have the IUIX_Dialog, you can hide the Advanced button by using https://sdkhelp.tracker-software.com/vi ... g_ShowItem:

Code: Select all

dlg.ShowItem("btn.advanced", false);
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Tue Sep 10, 2019 10:14 am

Hi Alex,

Thanks. I'll take a look...

How about:

Something like
PXV_Control1.Inst.ExecUICmd('cmd.addLink.goto', nil);
or
PXV_Control1.Inst.ExecUICmd('cmd.addLink.launch', nil);

But for GOTOR.

So to directly call the GOTOR UI ?


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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Tue Sep 10, 2019 12:34 pm

Hello zarkogajic,

Sadly, no such command is available.

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Tue Sep 10, 2019 1:38 pm

Alex,

Ah :( Any chance such command will be added ?

Btw, this topic: viewtopic.php?f=66&t=30597&p=122214&hil ... og#p122214

How do I know the name of dialog for "cmd.addLink.goto", like how "DlgSplitPages" was used in that code?

You mention some "Resources.dat" but I do not see where to find this.

?

Also, for "dlg.ShowItem("btn.advanced", false);" - where to get button names like ""btn.advanced"



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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Tue Sep 10, 2019 2:03 pm

The Resources.dat is located near the dlls that you have installed with Editor SDK. Inside it there is a DlgTemplates.xml file that holds all of the dialogs.

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Tue Sep 10, 2019 2:55 pm

Hi Alex,
Sasha - Tracker Dev Team wrote:
Tue Sep 10, 2019 6:58 am
viewtopic.php?f=66&t=30597&p=122214&hil ... og#p122214
After you have the IUIX_Dialog, you can hide the Advanced button by using https://sdkhelp.tracker-software.com/vi ... g_ShowItem:

Code: Select all

dlg.ShowItem("btn.advanced", false);
I have the EventMonitor running, listening for "e_ShowModal" but it does not work for the "Browse for link target" dialog - as this is not a modal window.

Any idea?

p.s.
When I click the "Advanced..." button (the one I want to hide) it does fire for "Edit Action List" window - as this one is modal.


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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Tue Sep 10, 2019 2:56 pm

Hello zarkogajic,

Well there is an easier way for you - just remove that button from the xml itself - nothing more is needed.

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Tue Sep 10, 2019 3:24 pm

:) Well, that's a straightforward approach.

Yes, but that would remove it for good. I want to do it programmatically (if possible) as in some scenarios I want the user to have it and in some not.

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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Wed Sep 11, 2019 9:35 am

Hello zarkogajic,

You should get the needed dialog as advised here (only use your ID):
viewtopic.php?f=66&t=27795&hilit=find+dialog#p108843

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Wed Sep 11, 2019 10:45 am

Hi Alex,

Thanks that helped. However I would again need some help from your Delphi-guy :)

Attached is a sample application.

I cannot get past one line of code:

Code: Select all

function TIUIX_EventMonitor.OnEventMonitor(const pTarget: IUIX_Obj; const pEvent: IUIX_Event): HResult;
...
    guid := GetTypeData(TypeInfo(IUIX_Dialog))^.Guid;
    pTarget.QueryImpl(guid, nil, outPtr);

    //Access Violation here
    dlg := IUIX_Dialog(outPtr);
I've tried various approaches to get from that pointer (outPTR) to the IUIX_Dialog dlg instance - but all failed...
image.png
image.png (15.36 KiB) Viewed 1351 times
To test: click the button "btnLoadFIle", then "btnLinkTool" and do a rectangle to activate the link tool dialog.

Attachments
pdfxchange-eventmonitoring.zip
(52.87 KiB) Downloaded 27 times

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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Wed Sep 11, 2019 1:57 pm

Hello zarkogajic,

Forwarded this one to him. Will reply back when he'll have some time to look at this one.

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Thu Sep 12, 2019 2:56 pm

Hi Alex,

I got it working, no need to bother your Delphi-guy :)


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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Fri Sep 13, 2019 6:58 am

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Wed Nov 06, 2019 4:19 pm

Hi Alex,
Sasha - Tracker Dev Team wrote:
Tue Sep 10, 2019 12:34 pm
Sadly, no such command is available.
I'm waking up this topic, just to double/triple check something...

In this post viewtopic.php?f=66&t=28347&p=111997&hil ... st#p112175 you show how to hide the "cmd.actions.add" command.

Such a command does not exist (any more) correct (so that code does not apply any more)?

I can get to the "DlgEditActionsList" dialog and monitor it, but that top "command line" is not a part of dialog items.

Is there ANY way to hide some of the actions listed from that "Add..." menu?

image.png

Is there ANY way to initiate adding any of the listed action like GOTO or GOTOR or Launch without the need to select from the drop down?

-žarko

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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Wed Nov 13, 2019 11:00 am

Hello žarko,

Here's a code sample -it show you how the command IDs are formed, how to call them and also the access to the SubMenu to remove the unneeded ones:

Code: Select all

public static PDFXEdit.IUIX_ScrollContainer GetParentScrollContainer(PDFXEdit.IUIX_Obj obj)
{
	if (obj.Parent != null)
	{
		IntPtr outPtr;
		obj.Parent.QueryImpl(typeof(PDFXEdit.IUIX_ScrollContainer).GUID, null, out outPtr);
		PDFXEdit.IUIX_ScrollContainer sc = (PDFXEdit.IUIX_ScrollContainer)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
		if (sc != null)
			return sc;
		return GetParentScrollContainer(obj.Parent);
	}
	return null;
}


if ((pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_ShowModal)) //launched after the BeginModal
{
	if (pTarget.ID == pTarget.ThreadCtx.Inst.Str2ID("DlgEditActionsList"))
	{
		IntPtr outPtr;
		pTarget.QueryImpl(typeof(PDFXEdit.IUIX_Dialog).GUID, null, out outPtr);
		PDFXEdit.IUIX_Dialog dlg = (PDFXEdit.IUIX_Dialog)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
		if (dlg == null)
			return;
		PDFXEdit.IUIX_List lst = null;
		PDFXEdit.IUIX_Obj obj = dlg.GetItem("actions");
		if (obj != null)
		{
			obj.QueryImpl(typeof(PDFXEdit.IUIX_List).GUID, null, out outPtr);
			lst = (PDFXEdit.IUIX_List)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
		}
		if (lst == null)
			return;
		IUIX_ScrollContainer sc = GetParentScrollContainer(obj);
		if (sc == null)
			return;
		IUIX_CmdBar bar = sc.CmdPaneTop[0][0];
		if (bar == null)
			return;
		IPXS_Inst pxsInst = (IPXS_Inst)m_Inst.GetExtension("PXS");
		IUIX_CmdItem itAdd = bar.FindFirstItemByCmdName("cmd.actions.add");
		for (uint i = 0; i < m_Inst.ActionHandlersCount; i++)
		{
			IPXV_ActionHandler ah = m_Inst.ActionHandler[i];
			if ((ah.Flags & (int)PXV_ActionHandlerFlags.AHF_Hidden) != 0)
				continue;
			int nID = m_Inst.Str2ID(pxsInst.AtomToStr(ah.Type));
			int nIndex = itAdd.SubMenu.FindFirstItemByCmdID(nID);
			IUIX_Cmd subCmd = itAdd.SubMenu.FindFirstCmd(nID);
			subCmd.Handler.OnNotify((int)UIX_CmdNotifyCodes.UIX_CmdNotify_Exec, subCmd, null, null, 0);
			break;
		}
	}
}

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Thu Nov 14, 2019 1:16 pm

Hi Alex,

Thanks much, this works!

A confirmation please: all those commands (like "cmd.actions.add") are created/generated on the fly and removed when the dialog is no longer used? As if I go over CmdManager.Cmds they are not there.


p.s.
In your code "GetParentScrollContainer(obj);" should actually be "GetParentScrollContainer(lst.Obj);"


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

Re: Add link action for GOTOR  SOLVED

Post by Sasha - Tracker Dev Team » Thu Nov 14, 2019 1:30 pm

Hello žarko,

These commands are not registered in the Command Manager - thus they only live until the dialog is opened and to get to them, such complicated coding is required. And yes, the list's object should be used to obtain it's parent scroll container.

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

zarkogajic
User
Posts: 650
Joined: Thu Sep 05, 2019 12:35 pm

Re: Add link action for GOTOR

Post by zarkogajic » Thu Nov 14, 2019 2:33 pm

Thanks Alex, time to "solved" this topic :)


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

Re: Add link action for GOTOR

Post by Sasha - Tracker Dev Team » Thu Nov 14, 2019 2:57 pm

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

Post Reply