» Back to Documentation

One of the most widely used functions in a custom tool is the usage of dialogs to represent user interface. With 3dsmax, however, there is a problem with entering text into them. The reason for this lies in the way 3dsmax handles its own shortcuts.

The degault behaviour of 3dsmax is to 'hijack' all keyboard input (except ctrl/alt/shift keys) and map it into its keyboard layout configuration. There is, however, a work-around that allows developers to create dialogs where text can be entered:

Entering text into dialogs

  1. Override a dialog's OnShown(...) and OnClosing(...) events
  2. Add IPlugin.Instance.Global.DisableAccelerators(); to OnShown(...) event and Plugin.Instance.Global.EnableAccelerators(); to OnClosing(...) event.

Example code:

 

protected override void OnShown( EventArgs e )
        {
            Plugin.Instance.Global.DisableAccelerators();
            base.OnShown( e );
        }

        protected override void OnClosing( CancelEventArgs e )
        {
            Plugin.Instance.Global.EnableAccelerators();
            base.OnClosing( e );
        }

 

Entering text into a specific textbox only

  1. Add a custom delegates for your textbox's (or any other control's) Enter and Leave events.
  2. Add IPlugin.Instance.Global.DisableAccelerators(); to Enter delegate and Plugin.Instance.Global.EnableAccelerators(); to Leave delegate.

Example code:

 

this.palettePicker.Leave += new System.EventHandler( this.palettePicker_Leave );
            this.palettePicker.Enter += new System.EventHandler( this.palettePicker_Enter );

 

private void palettePicker_Enter( object sender, EventArgs e )
        {
            Plugin.Instance.Global.DisableAccelerators();
        }

        void palettePicker_Leave( object sender, EventArgs e )

 

        {           
Plugin.Instance.Global.EnableAccelerators();
}

This is prevent 3dsmax from executing any shortcuts while your dialog or control is in focus thus allowing user input. This is also the method recommended by 3dsmax developers.