PDA

View Full Version : dotnet keydown event


jlueck
04-10-2007, 11: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?

ypuech
04-11-2007, 09:14 AM
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.

jlueck
04-11-2007, 06: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.

ypuech
04-12-2007, 09:49 AM
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
)

jlueck
04-12-2007, 06:59 PM
Cool! That works great. Thank you very much.

CGTalk Moderation
04-12-2007, 06: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.