Webbrowser control enter key not being picked up

Webbrowser control enter key not being picked up

Anonymous
Not applicable
2,152 Views
7 Replies
Message 1 of 8

Webbrowser control enter key not being picked up

Anonymous
Not applicable

Hi all, 

 

I've got a panel inside of Revit that has a webbrowser control inside of it. The webbrowser has a textarea that is used to send feedback about the webpage, the issue is that when a user types inside of this textarea and tries to use the enter key for a carriage return, nothing happens. 

 

I've tried putting in some basic javascript to check for the key press and this works for pretty much every key except the enter key. 

 

Is there anything inside of Revit that would stop the webbrowser from recieving the enter key press event?

Accepted solutions (1)
2,153 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Hello Andrew

 

I'm facing the exact same issue on my end trying to host a WebBrowser control inside the Revit add-in, using the WindowsFormsHost control. This works in a separate XAML app, but not inside the Revit add-in. Did you ever get a solution to your issue? 

 

Thanks

Sameeksha

0 Likes
Message 3 of 8

JimJia
Alumni
Alumni

I'm communicating with engineering team on this, we'll get this updated on any progress.

Thanks for your great patience and understand.

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 4 of 8

JimJia
Alumni
Alumni

 

Per communication with engineering team, it's confirmed this is known issue in Revit dockabke pane.

Revit engineering team already created issue REVIT-143199 [Some keyboard keys not handled properly in Winforms Textboxes when inside an API Dockable View] which was already fixed in newer Revit version however the released Revit 2019 versions are not integrated. 

 

To solve this issue in present Revit version, you may consider to use windows API IKeyboardInputSink to manager the key events, see MSDN here:

https://docs.microsoft.com/en-us/dotnet/api/system.windows.interop.ikeyboardinputsink?view=netframew...

 

Besides, we provided one simple code snippet for your reference, please also refer to attached sample project for your convenience:

public class RevitCustomPropertiesHost : WindowsFormsHost, IKeyboardInputSink
   {
      [DllImport("user32.dll")]
      static extern bool IsDialogMessage(IntPtr hDlg, [In] ref Message lpMsg);

      bool IKeyboardInputSink.TranslateAccelerator(ref MSG msg, ModifierKeys modifiers)
      {
         if (base.TranslateAcceleratorCore(ref msg, modifiers))
            return true; // defer to base

#if (Revit2018 || Revit2019)
         // Give embedded controls chance to translate, to avoid keys such as delete etc.
         // being translated by Revit main UI before the contols get their chance. 
         Message m = Message.Create(msg.hwnd, msg.message, msg.wParam, msg.lParam);
         return IsDialogMessage(Handle, ref m);
#else
         // In newer Revit will take care of the translation for winform controls
         // embedded in a Dockable pane by default, however, the presence of the code above would
         // still work in that scenerio, it would just do it 1 step before the revit code would. 
         return false;
#endif
      }
   }

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 5 of 8

Anonymous
Not applicable
Accepted solution

Hello Jim, thanks for your response and for the code snippets.

However when i tried this add-in on my machine with Revit2019 i still see the same behavior of Enter key not being recognized. Even the sample app you provided shows the same behavior.

 

When i debugged into it, it hits the RevitCustomPropertiesHost, and goes into the conditional compilation for revit 2019, and executes  return IsDialogMessage(Handle, ref m); to be "true". However the behavior i see on the UI is still that the Enter key is not respected.

 

Also my original problem is a slight variation of the this sample code. This code attempts to fix it for WinForm textboxes control within Webbrowser control, while i want to have Enter key working in an editable webpage whose url is supplied to the WebBrowser control. They may be the same underlying issue since i see that Enter is not working for the WinForm text controls for me too.

 

Please advise. This issue has been continuing for months.

 

-Sameeksha

0 Likes
Message 6 of 8

Anonymous
Not applicable

Hello Jim

 

The sample code did not help solve my problem. The issue is not resolved.

The sample app you provided also does not respect the Enter key being hit inside WebBrowser control.

Please let me know what next steps i should try to get this resolved.

 

Thanks

Sameeksha

0 Likes
Message 7 of 8

JimJia
Alumni
Alumni

Dear Sameeksha,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue. 

 

Can you provide a reproducible case for it? because you said your original problem is different from the sample code.


In order to explore this matter further, we will need to provide a minimal reproducible case for the development team to analyse in depth.


In order to understand exactly what you mean and be able to research possible reasons for the discrepancy between the observed and expected behaviour, they require: 
· A short exact description of what you are trying to achieve.
· The behavior you observe versus what you expect, and why this is a problem.
· A complete yet minimal Revit sample model to run a test in.
· A complete yet minimal macro embedded in the sample model or Visual Studio solution with add-in manifest that can be compiled, loaded, run and debugged with a single click to analyse its behavior live in the sample model.
· Detailed step-by-step instructions for reproducing the issue, e.g. which element to pick, what command to launch etc.
· http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 8 of 8

Anonymous
Not applicable

Hi Jim

 

Sorry about the delay in posting. I have sent a complete sample to your email address with the issue still being present for Revit 2020. Could you please help me get this resolved? 

 

Thanks a ton

Sameeksha

0 Likes