[69462 Closed] Popup menu shortcuts not working in plugin

Hello,

I have a C# host and a Delphi visual plugin. The visual plugin has a popup menu where the popup shortcuts DO work. However, other Delphi forms can be launched from this plugin and it seems these forms are not working in the same way, so none of the keyboard shortcuts for the form’s popup menu work.

When this was a standalone program this all worked correctly.

Any ideas why this is happening?

Regards,

Rob

What versions of Hydra and Delphi do you use? Also can you please create a small testcase that reproduces this problem? You can send it to support@remobjects.com, thanks.

Hello,

I use XE5 and am one version behind with Hydra (March 2014).

All you have to do to reproduce it is to put a popup menu on the example “Unmanaged plugin module” in the mixed mode example, with a shortcut and you will see that shortcut does not work.

Regards,

Rob H

I guess i understand what is the problem, you are trying to press shortcut key in the .NET form, not in the plugin. There are two things:

  1. HostPanel handles only its own message, not application wide. So, if you need to run execute shortcut in a plugin you need to do this manually.

  2. While checking this, i’ve found that there is a problem with processing shortcuts in case there is no active control on a Delphi side, logged this for further review.

Thanks, logged as bugs://69462: Popup menu shortcuts not working in plugin

Thanks for the reply.

I guess i understand what is the problem, you are trying to press shortcut key in the .NET form, not in the plugin.

No, that’s not correct, I don’t expect it to work application wide. It does not work when on the Delphi plugin.

I don’t think it makes a difference if there is an active control or not, not in the test I told you about…

Regards,

Rob

Hm, this is weird, per your comment i’ve tried following:

  1. Added popup menu to a sample
  2. Created an item with a shortcut
  3. Hooked this popup menu to a TConverter form

but this works fine, and when focus is on the plugin side popup is shown when shortcut is pressed. Maybe i missed a step?

bugs://69462 got closed as fixed

Hello,

Is there a fix available to try?

Regards,

Rob

@robhoney72: this fix is available in the latest release. You can download it from our customers portla.

Thank you, I’ve downloaded it and tried it. It partially works. It works on the main “form”, but if you launch another form from within the plugin, it does not work on that form. Do you have any ideas why that might be?

Regards,

Rob

@robhoney72: Looks like this is the same problem as with plugins, Delphi handles shortcuts in different places and most of them is triggered by Application which is not available in the plugin.

Please try to modify your form like this:

uses
  uHYPluginHelpers, uHYCrossPlatformInterfaces;

type
  TYourRegularForm = class(TForm)
  [...]
  private
    Helper: IHYCrossPlatformVisualPluginEx;
  public
    function WantChildKey(Child: TControl; var Message: TMessage): Boolean; override;
  end;

procedure TYourRegularForm.FormCreate(Sender: TObject);
begin
  Helper := THYControlAsVisualPlugin.Create(self);
end;

function TYourRegularForm.WantChildKey(Child: TControl; var Message: TMessage): Boolean;
begin
  result := Helper.HandleShortCuts(Message.WParam);
end;

This will trigger same mechanism that Hydra uses to process shortcuts in a plugins.

Thanks, but it’s still not quite right, the shortcut is now called twice…

Yeah, this is because WantChildKey receives multiple message, we can filter them to take only key down, like this:

function TYourRegularForm.WantChildKey(Child: TControl; var Message: TMessage): Boolean;
begin
  if Message.Msg = WM_KEYDOWN then
    result := Helper.HandleShortCuts(Message.WParam)
  else 
    result := false;
end;

I implemented this and it worked.

Thank you,

Rob

I have just downloaded and installed the latest release (May 2016) and now the shortcuts no longer work again. Before the upgrade, they were working fine. Why might this be?

Regards,

Rob H

can you create a simple testcase that illustrates this problem, pls?
you can attach it here or send directly to support@

Hello,

While putting the example together for you, I saw that everything seemed to be working again, so perhaps it was something else. I’ll monitor it, but there may not be a problem, sorry.

Rob