1

Apologies for the kind-of unrelated questions in one, but I would like to make my MaxScript rollout/tool more intuitive by making it behave like any other GUI would be expected to.

Could anyone familiar with MaxScript tell me:

  1. How do I 'disable' (grey out) a button?

  2. How do I get the Enter key pressed event? (I.e. I have an EditText control. When enter is pressed anywhere in this form I would like to close the dialog (it is not a multiline control))

  3. How do I give focus to a control? (I.e. I would like my rollout opened with CreateDialog to give focus to the EditText control so the user can start typing immediately)

sebf
  • 2,831
  • 5
  • 32
  • 50

3 Answers3

2

the first one would be setting its .enabled property to false. The second one depends on the type of control you are using, if it's the usual rollout control, just use on editTextName entered do ... event handler. For a dotnet one you'd have to use

    on editTextName KeyUp evnt do
        if evnt.KeyCode == (dotNetClass "System.Windows.Forms.Keys").Enter do ...

As for the third one, use setFocus method in your rollout open event handler:

    on myRollout open do setFocus editTextName

Hope this is what you were looking for.

Swordslayer
  • 2,061
  • 1
  • 13
  • 15
  • Thats great; its behaviour is much more sensible now! Thank you! Can I ask, when you started first learning MaxScript how did you find the documentation? (As in, what do you think of it) – sebf Jun 05 '11 at 15:26
  • Well, even though it might be sometimes hard to find what you're looking for in the help file, most of the time it's good enough. And for the rest of the commands you can't remember you can always use apropos (e.g. apropos "focus"). – Swordslayer Jun 05 '11 at 16:34
  • That is an excellent function! Thanks. I find the documentation very obtuse but am wondering if thats because I'm used to Winforms/MFC/Win32 & MSDN, and haven't quite got the style of the terminology right (I thought 'entered' was for when the user focused on the control, and I Never would have found SimpleFaceManager on my own), or if I am just being very dim! In any case I'm very glad to find that there are people on here who know MaxScript, to who I can ask these types of Qs. – sebf Jun 05 '11 at 16:44
  • My pleasure to be of assistance. Yeah, the documentation is indeed different and even the syntax is sometimes inconsistent (quite a few of the modules that are now included in the package were 3rd-party tools before). It has to do with the fact that maxscript itself originated as a scripting language designed for the artists – 1-based indexing, implicit declarations, case insensitive – and the help-file is the same in this regard so there's a FAQ section and How to Section dealing with the basic concepts. – Swordslayer Jun 05 '11 at 17:05
  • However, to find useful little things like verbatim string literal, by-reference parameter passing, :: globals access or dereferencing operator you have to dig really deep in the maxscript reference... – Swordslayer Jun 05 '11 at 17:05
0
mybutton.enabled = false

or

mybutton.enabled = off

since off is an alias for false

C.J.
  • 15,637
  • 9
  • 61
  • 77
-1

1.How do I 'disable' (grey out) a button?

Where you add a button or another component to the floater you add enabled:false as method just like height:buttonheight sample: button btnviewdistline "View distance line" width:btnWidth height:btnHeight enabled:false

clarenburg
  • 44
  • 2