Notifications
Clear all

[Closed] dotnet keydown event

I have a script that has a dotnet form with various controls. My problem is that any keydown event that is raised is raised by max itself not the form. If I type in a textbox nothing shows up but if I hit a key associated with a hot key in max, it triggers that hot key function. If I use the ShowDialog() function to show the form everything works fine but the Show() method has the problem and I need to use the Show() method. Has anyone else had this problem?

4 Replies

Hi,

Maybe the problem comes from the focus. Add this after showing the form:

hForm.focus()

But, I recommend to use rollouts instead of forms and create .Net controls into them using dotNetControl.

I have tried that as well and it acts the same. It only seems to work using the ShowDialog() method to show the form.

Hi,

I found a solution using a DotNet Application. The TextBox handles the key events. This solution doesn’t use show() or showdialog().

Here is the code:

(
 -- Create a DotNet TextBox
 hTextBox = dotNetObject "System.Windows.Forms.TextBox"
 hTextBox.size = dotNetObject "System.Drawing.Size" 160 25
 hTextBox.location = dotNetObject "System.Drawing.Point" 20 20
 
 -- Create a DotNet Form
 hForm = dotNetObject "System.Windows.Forms.Form"
 hForm.size = dotNetObject "System.Drawing.Size" 200 100
 hForm.controls.add hTextBox
 hForm.topmost = true
 
 -- Create a DotNet Application to run the form
 hApp = dotNetClass "System.Windows.Forms.Application"
 hApp.run hForm
 )

Cool! That works great. Thank you very much.