View Full Version : dotnet keydown event

04 April 2007, 10:00 PM
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?

04 April 2007, 08:14 AM

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


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

04 April 2007, 05:14 PM
I have tried that as well and it acts the same. It only seems to work using the ShowDialog() method to show the form.

04 April 2007, 08:49 AM

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" hForm

04 April 2007, 05:59 PM
Cool! That works great. Thank you very much.

CGTalk Moderation
04 April 2007, 05:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.