SWT hotkeys and menu problem

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

SWT hotkeys and menu problem

Post by Arne »

I'm using the PDFXchangeViewer-ActiveX Control in an SWT window. Everything works fine, except of two things:

1.) I can't find a solution to get SWT hotkeys working. I have a menu bar with items, and I set Accelerators with the setAccelerator() method of the MenuItem class. I suspect, they get blocked by the ActiveX-Control. However, I am able to open the menu bar by holding down the alt key and the special character key of a MenuItem key (by "special character", I mean the character in the name of the MenuItem-text, which is underlined).

2.) If I only press the alt-key and release it immediately without pressing another key, I can see switching the menu to blue (indicating it's getting activated). But after that, the whole application blocks and I have to kill it.

Any ideas?

I tried to create a minimal example, which shows the described bevaviour:

Code: Select all

public class Main
{
  private static Shell shell;

  private static Display display;

  /**
   * @param args
   */
  public static void main(String[] args)
  {
    display = new Display();
    shell = new Shell(display);

    Menu menuBar = new Menu(shell, SWT.BAR);

    MenuItem header = new MenuItem(menuBar, SWT.CASCADE);
    header.setText("&Header");

    Menu ectrMenu = new Menu(shell, SWT.DROP_DOWN);
    header.setMenu(ectrMenu);

    MenuItem cancel = new MenuItem(ectrMenu, SWT.PUSH);
    cancel.setText("&TestItem");
    cancel.addSelectionListener(new SelectionListener()
    {

      @Override
      public void widgetSelected(SelectionEvent arg0)
      {
        System.out.println("Test");
      }

      @Override
      public void widgetDefaultSelected(SelectionEvent arg0)
      {
        System.out.println("Test");
      }
    });

    cancel.setAccelerator(SWT.CTRL + 'G');

    shell.setMenuBar(menuBar);

    GridLayout gridLayout = new GridLayout();

    shell.setLayout(gridLayout);

    OleFrame frame = new OleFrame(shell, SWT.NONE);

    OleControlSite controlSite = new OleControlSite(frame, SWT.NONE, "PDFXCviewAx.CoPDFXCview");
    controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    controlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    frame.setLayoutData(gridData);

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
  }
}
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SWT hotkeys and menu problem

Post by Vasyl - PDF-XChange »

Hi Arne.

Thanks for your example code.
We will investigate and try to fix this problem.

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

Any news here?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SWT hotkeys and menu problem

Post by Vasyl - PDF-XChange »

Hi, Arne.

This issue reproduced and will be fixed in the next build (upcoming).
See also some our modifications in your example code in the attached archive.

Best
Regards.
You do not have the required permissions to view the files attached to this post.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

Thanks a lot. I'm looking forward to the new release.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: SWT hotkeys and menu problem

Post by John - Tracker Supp »

Pleasure ;)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

Most of the stuff seems to work, now. Thank you.

I'm now able to capture key combinations of the ALT key plus any other key with the example you gave me (with CheckSysKey). However, I cannot find a way to capture combinations of CTRL plus another key. Because I always get separated events for the CTRL key and the other key.

Do you know a solution for this?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SWT hotkeys and menu problem

Post by Vasyl - PDF-XChange »

Hi, Arne.

You may use the followng method:

Code: Select all

OnEvent(type, name, dataIn...)
{
     if ((type == PXCVA_OnNamedNotify) && (name == "CheckKey"))
     {
           if (GetAsyncKeyState(17) < 0)
           {
                // the 'Ctrl' is pressed... look to dataIn for key code
           };
     };
};
About GetAsyncKeyState: http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

Thank you.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: SWT hotkeys and menu problem

Post by Stefan - PDF-XChange »

You are welcome Arne!

:)
Best,
Stefan
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

I still have a problem with hotkeys. In my scenario, I press a hotkey to open several PDFs in a window. That works fine. If I close all the windows with the PDFs, my Hotkey stops working. As long as at least one PDF is opened, it works.

Also in the beginning, when there are no PDFs opened, the hotkey works. It just stops working after closing all the PDFs. Do you know, what is happening here?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SWT hotkeys and menu problem

Post by Vasyl - PDF-XChange »

Hi, Arne.
If I close all the windows with the PDFs, my Hotkey stops working. As long as at least one PDF is opened, it works.
You talking about our hotkeys (control's internal hotkeys) or about your own Hotkey, used in your application?
May be here is problem with input focus. You may change the input focus forcedly to our control or to your application in:

Code: Select all

ax.OnEvent(type, name, ...)
{
      if ((type == PXCVA_OnPropertyChanged) AND (name == "Documents.Count"))
      {
          // change input focus to other window
      }
};
If it does not help you - please give us the simple example for reproducing. Thanks.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

I am talking about my own hotkey and I am using SWT in Java. I am not sure, how to change the input focus between the control or the application. But I will post a minimal example, soon.
Arne
User
Posts: 15
Joined: Tue Nov 10, 2009 1:11 pm

Re: SWT hotkeys and menu problem

Post by Arne »

Never mind, I found an easier way to achieve my tasks. Thanks anyway.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: SWT hotkeys and menu problem

Post by Stefan - PDF-XChange »

Hi Arne,

That's good to hear, so we will count this case closed.

Best,
Stefan