Rhino.Inside Key Input Not Normal

After switching to Rhino.Inside recently for our application, we are finding that the DELETE key and the ENTER key emit a warning sounds from Windows as if input is disabled, but the ENTER key still works, while the DELETE key does not.

We cannot delete objects in the document with the DELETE key. We can type “delete” and it will delete.

This is in Rhino 7 sr17 running inside a WPF application host.

1 Like

Just to be certain this issue isn’t our application, I created a brand new empty WPF project, referenced the Rhino.Inside NuGet package and RhinoCommon, then added the minimum code to reproduce the issue.

Starting the application and clicking the start Rhino.Inside button launches Rhino, but then the same issue exists. You cannot click the DELETE button and have the application respond. Instead Windows chimes with the invalid input sound effect.

Attached is the sample solution exhibiting the problem.
KeyHandlerBugRhinoInside.zip (63.8 KB)

Any help would be appreciated @scottd

@fraguada @stevebaer do either of you guys have any clue on my input issue? Just curious if you’ve heard of anyone else having problems running Rhino.Inside their application, and sending ENTER/DELETE to the Rhino process?

Thanks for your time!

@kike have you run into this issue when building rhino.inside revit?

Yes I did.

In Rhino.Inside.Revit this problem was solved when we move to our own message loop. This was a good enough solution in that case because other restrictions Revit API imposes, but makes the Rhino window “modal”.

We need a diferent solution here.
Rhino uses MFC CWinThread::PreTranslateMessage and this method is not called when running in a non MFC message loop.
Same happens with CWinThread::OnIdle is not called because of the same reason.

I think we should pay attention to ComponentDispatcher Class (System.Windows.Interop)

Would you be able to share any source for running your own message pump? I see that the RhinoCore object has the Run(), DoEvents(), DoIdle() and RaiseIdle() methods. I’ve had minimal lucking calling Run() because I usually get: System.InvalidOperationException: ‘Operation is not valid due to the current state of the object.’

Just looking for any sample you can share. Thanks for the response.

Run can only be called on the same thread RhinoCore was created.

@kike I tried doing everything on that same thread and getting this, any ideas?

image

OK, I got this working, sort of. I had to use the WPF UI Thread, any other thread caused those other issues. Well this is probably a bad idea, but it is working, I just worry how often the WPF message pump goes idle and calls the Run().