Tab menu in multi tab mode  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

Tab menu in multi tab mode

Post by zarkogajic » Thu Nov 21, 2019 10:45 am

Hi support,

Now that I know more about how this all works :) I'd like to "reopen" a topic I asked before...

So, is there a way (never mind how complex) to customize (add/remove items) or react on command items in the tab menu:

image.png
image.png (55.38 KiB) Viewed 1234 times


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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Thu Nov 21, 2019 11:24 am

Hello zarkogajic,

Like I said before, there is no way of doing that now.

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: Tab menu in multi tab mode

Post by zarkogajic » Thu Nov 21, 2019 12:17 pm

ok, thanks.

Let's hope for it ... :)


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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Fri Nov 22, 2019 7:05 am

:)
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: Tab menu in multi tab mode

Post by zarkogajic » Fri Nov 22, 2019 8:20 am

Hi Alex,

I think you mentioned I could display my own menu for the tab (as currently I'm hiding the default one).

So, how to display my own menu for tab (and re-use most of the default menu items) ?


-žarko

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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Fri Nov 22, 2019 10:02 am

Hello žarko,

First you will have to create an IUIX_CmdMenu by using the https://sdkhelp.tracker-software.com/vi ... ateCmdMenu method.
After that, you can fill it with the needed commands by using this method or one of the other 3: https://sdkhelp.tracker-software.com/vi ... nsertItem4
After that you will have to display that menu. For that you will have to use the https://sdkhelp.tracker-software.com/vi ... wPopupMenu method and pass your menu there.
In case of the Tab popup menu, you should use the "documentViewsArea" IUIX_Obj as a pSender, the LeftTop and RightBottom of the rectangle should be the point of the Current Cursor Position (screenwise coordinates) and you should specify the true value for the result returning.
If you do all of this, you should be able to replace that menu with your custom 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: Tab menu in multi tab mode

Post by zarkogajic » Fri Nov 22, 2019 1:52 pm

Hi Alex,

Thanks, sounds straightforward and doable :)

I know the tab menu is generated dynamically, and I think commands as well - so I cannot use (some of the) the same commands in my custom menu?


-žarko

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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Fri Nov 22, 2019 2:46 pm

Hello žarko,

You can use all of the needed commands from that menu - they do have their command handlers, so basically, you will just have to add the needed commands. Here's a list of all the commands that can be there in current logic:
id_cmd_duplicateTab
id_cmd_renameDoc
id_cmd_closeTab
id_cmd_closeOtherTabs
id_cmd_closeTabsToTheRight
id_cmd_closeTabsToTheLeft
id_cmd_sortAllTabsAbc
id_cmd_copyTabSrcFileName
id_cmd_openTabSrcFolder
id_cmd_reopenJustClosedDoc
id_cmd_moveTabToTrash

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: Tab menu in multi tab mode

Post by zarkogajic » Fri Nov 22, 2019 3:25 pm

Alex,

Great!

I'll "solved" the topic once I have it implemented :)

-žarko

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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Fri Nov 22, 2019 4:36 pm

:)
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: Tab menu in multi tab mode

Post by zarkogajic » Sat Nov 23, 2019 10:28 am

Hi Alex,

Here's what I have and the popup is displaying and the result of the popup is the id of the clicked menu item's command - however nothing happens:

Code: Select all

  cmdMenu := InstUI.CreateCmdMenu;
  cmdMenuC1 := cmdMenu.InsertItem4('cmd.closeTab', 'cmd.closeTab Text', UIX_CmdItemState_Normal, nil, 'cmd.closeTab Tip', -1, 0);
  cmdMenuC2 := cmdMenu.InsertItem4('cmd.openTabSrcFolder Text', 'cmd.openTabSrcFolder', UIX_CmdItemState_Normal, nil, 'cmd.openTabSrcFolder Tip', -1, 0);

  //cmdHandler := cmdMenuC1.Cmd.Handler; <- there is a handler

  //i := cmdMenuC1.Cmd.ID;
  //i := cmdMenuC2.Cmd.ID;

  retCmdID := InstUI.CmdManager.ShowPopupMenu(pSender, cmdMenu, menuRect, true, 0);
After the click nothing happens. I've also tried:

Code: Select all

  //nothing happens
  cmdMenuC1.Cmd.Handler.OnNotify(UIX_CmdNotify_Exec, cmdMenuC1.Cmd, nil, pSender, 0);

  // error result as this command is not registered in Cmd manager
  InstUI.CmdManager.ExecCmd2(retCmdID, pSender);
Further, since the CmdManager.Cmds does not have those commands registered, how can I grab the icon and use it in InsertItem4, for example? Or a more general question: obviously InsertItem4 knows about this command (or simply generates all on the fly even if such a command does not exist?!) and the command manager does not, so how can I get to IUIX_Cmd if it is not in registered commands?


Finally, if I need to do all from code (get the popup result any apply my code as action), so cannot reuse those commands, how do I get the tab (index) and the document so to know what tab/document to close, for example.

-žarko

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

Re: Tab menu in multi tab mode  SOLVED

Post by Sasha - Tracker Dev Team » Tue Nov 26, 2019 8:54 am

Hello žarko,

What I see from code, is that the implementation of the commands is being done right after the popup is closed, meaning that if you want to use this behavior, the implementation should be done by your side.
For example, for the id_cmd_closeTab, the DocumentViewsArea.Panes.Hide(docView); code should be used.
Also, to obtain the IPXV_View from tab:
1) The IUIX_LayoutItem should be obtained from the UIX_NotifyInfo.pData (simple cast with the null check should be OK) - let's call it pTab.
2) Then the IUIX_Obj should be obtained pTab and checked whether it's a scroll container. For that we should try casting it's implementation to the IUIX_ScrollContainer interface.
3) If successful, then we should use the IUIX_ScrollContainer::Client property to get the IUIX_Obj - that should be the object of the IPXV_View.
4) Try casting the implementation of the object to the IPXV_View.
5) If needed, the IPXV_View then can be cast to the IPXV_DocumentView.
Here's how to get the object's implementation (for example the IPXV_SearchView):

Code: Select all

IntPtr outPtr;
view.Obj.QueryImpl(typeof(PDFXEdit.IPXV_SearchView).GUID, null, out outPtr);
PDFXEdit.IPXV_SearchView SV = (PDFXEdit.IPXV_SearchView)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
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: Tab menu in multi tab mode

Post by zarkogajic » Tue Nov 26, 2019 11:45 am

Hi Alex,

Yes! This was the missing puzzle piece: " IUIX_LayoutItem should be obtained from the UIX_NotifyInfo.pData".

Since I'm custom handling the "documentViewsArea" and looking for e_Notify in OnEvent and reacting on UIX_Notify_Layout_ShowContextMenu (not displaying the original), the only thing that I needed to do is:

- get the layoutItem,
- get the index of the layoutItem from its parent by layoutItem.Parent.GetItemIndex(layoutItem);
- get the IPXV_DocumentView from the layoutItem.Obj's parent tree
- figure out what commands I need in my menu (depending on the index of the tab) to mimic and voila:

image.png
image.png (18 KiB) Viewed 1180 times
case closed :)


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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Tue Nov 26, 2019 12:39 pm

:)
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: Tab menu in multi tab mode

Post by zarkogajic » Tue Nov 26, 2019 6:00 pm

Hi Alex,

Out of curiosity: if I do layoutItem.Remove() the tab will be lost (/"closed"), but what happens with the document (/IPXV_DocumentView) that tab "hosts" (it seems the document does not get closed)?

-žarko

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

Re: Tab menu in multi tab mode

Post by Sasha - Tracker Dev Team » Wed Nov 27, 2019 8:20 am

Hello žarko,

Forwarded this one to Vasyl - will reply back when he tells more.

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

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1983
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Tab menu in multi tab mode

Post by Vasyl-Tracker Dev Team » Fri Nov 29, 2019 2:36 am

Hi žarko.

when layoutItem represents the document-tab:

Code: Select all

PDFXEdit.IPXV_Document doc = pdfCtl.Doc;
PDFXEdit.IPXV_DocumentView docView = doc.ActiveView;
PDFXEdit.IUIX_LayoutItem layoutItem = docView.Obj.Parent.LI;
then, to close properly the document-tab and related document too - use the:

Code: Select all

layoutItem.Hide()
because the layoutItem.Remove() will just remove the layout item and detaches from itself the document-view and remains it visible..

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

Post Reply