Notifications
Clear all

[Closed] WPF in Max

hi james,

with textbox issues i have used the gotfocus and lostfocusevents to call enableaccelerators = true/false depending on the event. I have also used the similar managedservices.dll call of these methods directly from dotnet in custom user controls. I tend to call this a lot – it doesnt generally harm the interactivity however on a textbox you need to control when it happens a bit more. I inherited a textbox control to create a ‘maxtextbox’ that natively has this so i dont have to invoke it via MXS.
I’m wondering whether it’s dotnet or WPF, the problem is with how max deals with it and we will probably encounter similar issues!

  Thanks, but like I said, it's not an accelerator issue.  If that were the problem then typing into the box would trigger all sorts of stuff to happen as hotkeys were pressed.  But absolutely nothing happens when you type into the box.  And it's not just the text box, the same thing happen in the editable portion of a combo box (which is technically a text box, I know, but still).
 
 Have you ever had a modal dialog box open, waiting for you click the Okay button, but you didn't notice it was there and you start typing, only to here a bunch of pinging sounds?  That's what happens.  It's like the keyboard is just disabled completely at that point.
  
  Here's an updated version of the test with acceleratos disabled when the text box gets focus to show that it still doesn't work...
dotNet.loadAssembly @"C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/v3.0/WindowsFormsIntegration.dll"
      rollout rlt "" width:200 height:45
      (
        dotNetControl tb "TextBox" Text:"WinForm" width:200 height:20 align:#left offset:[-14,-5]
        dotNetControl eh "Integration.ElementHost" width:200 height:20 align:#left offset:[-14,0]
        local wpfTb
         
         fn startFocus arg =
         (
      	   enableAccelerators = false
      	   print enableAccelerators
         )
         fn stopFocus arg =
         (
      	   enableAccelerators = true
      	   print enableAccelerators
         )
        on rlt open do
        (
      	 uc = dotNetObject "System.Windows.Controls.UserControl"
      	 eh.child = uc
      	 wpfTb = dotNetObject "System.Windows.Controls.TextBox"
      	 wpfTb.height = 20
      	 wpfTb.text = "WPF"
      	 dotNet.addEventHandler wpfTb "GotFocus" startFocus
      	 dotNet.addEventHandler wpfTb "LostFocus" stopFocus
      	 dotNet.setLifetimeControl wpfTb #dotNet
      	 uc.content = wpfTb
        )
      )
      
      createDialog rlt

I can type in the box, but before that I get an error saying,

–Unknown property: “Child” in dotNetControl:eh:(null)

1 Reply
(@jhaywood)
Joined: 11 months ago

Posts: 0

There are supposed to be two text boxes. I’ve edited the previous post to remove some extra tabs and spaces in the ‘loadAssembly’ line which probably caused it to not load correctly. Try again.

Page 3 / 3