Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

MAXSCRIPT: Textfield Multiline Scrollbar

interpolator
Offline / Send Message
SimonT interpolator
I can scale up a textfield in Maxscript and it will become a multiline textfield - my problem: it gets no scrollbar when the text is longer than the textfield. :(

Question:

1. How i can add scroll bars to the 3ds max textfield
2. OR: how i use a dotnet textbox?

Replies

  • Swordslayer
    Offline / Send Message
    Swordslayer interpolator
    As for the second part, here's example dotnet textbox:
    1. try destroyDialog test catch()
    2. rollout test " .NET Textbox" width:180 height:180
    3. (
    4. dotNetControl dncText "System.Windows.Forms.Textbox" width:175 height:170 align:#center
    5.  
    6. on test open do
    7. (
    8. dncText.Font = dotNetObject "System.Drawing.Font" "MS Sans Serif" 8 ((dotNetClass "System.Drawing.FontStyle").Regular)
    9. dncText.BorderStyle = (dotNetClass "System.Windows.Forms.BorderStyle").FixedSingle
    10. dncText.BackColor = (dotNetClass "System.Drawing.Color").fromARGB (((colorMan.getColor #background) * 255)[1] as integer) (((colorMan.getColor #background) * 255)[2] as integer) (((colorMan.getColor #background) * 255)[3] as integer)
    11. dncText.ForeColor = (dotNetClass "System.Drawing.Color").fromARGB (((colorMan.getColor #text) * 255)[1] as integer) (((colorMan.getColor #text) * 255)[2] as integer) (((colorMan.getColor #text) * 255)[3] as integer)
    12. dncText.MultiLine = true
    13. dncText.WordWrap = true
    14. dncText.ScrollBars = (dotNetClass "System.Windows.Forms.ScrollBars").Vertical
    15. dncText.Text =
    16. "I can scale up a textfield in Maxscript and it will become a multiline textfield - my problem: it gets no scrollbar when the text is longer than the textfield.\r\n\r\n
    17. Question:\r\n\r\n
    18. 1. How i can add scroll bars to the 3ds max textfield\r\n
    19. 2. OR: how i use a dotnet textbox?"
    20. )
    21. )
    22. createDialog test

    To comment what's happening in there:
    dotNetControl dncText "System.Windows.Forms.Textbox" -- this is how you declare the dotnet textbox in case you're using it in regular maxscript rollout; you can as well just say dotNetControl dncText "Textbox"

    dncText.Font -- if you don't like the default one
    dncText.BorderStyle -- I guess you can say what this is; anytime you need to find out more about the properties/methods/events of the control, you can create one and query it:

    showproperties (dotNetObject "TextBox")
    showmethods (dotNetObject "TextBox")
    showevents (dotNetObject "TextBox")
    -- this is useful for assigning event handlers, you can then just say on MouseDoubleClick args dncText do ...

    It also gives you the classes/objects you need to assign to the property to change it. However with the properties there's a shorthand possibility:

    instead of:

    dncText.ScrollBars = (dotNetClass "System.Windows.Forms.ScrollBars").Vertical

    you can just say:

    dncText.ScrollBars = dncText.ScrollBars.Vertical

    The backcolor assignment I use there gets the interface colors, that's why it might look so intimidating. In fact it could be just

    dncText.BackColor = dncText.BackColor.fromARGB 140 150 160

    or something like that. Anyway, there're quite many tutorials around (Paul Neale comes to mind) dealing with donet so even if this doesn't completely make sense, don't worry, ask for details or just search around for ready made scripts using it and you'll master it in no time.
  • SimonT
    Offline / Send Message
    SimonT interpolator
    You are my hero! Thank you very much! The only thing i miss is the AcceptReturn stuff.

    my code:
    rollout unnamedRollout "Untitled" width:389 height:279
    (
    dotNetControl textboxctrl "System.Windows.Forms.TextBox" pos:[16,16] width:232 height:200

    on unnamedRollout open do
    (
    textboxctrl.Multiline = true;
    textboxctrl.AcceptsReturn = true;
    textboxctrl.WordWrap = false;
    textboxctrl.ScrollBars = textboxctrl.ScrollBars.Both;
    )
    )

    createDialog unnamedRollout;

    But it does nothing. I'm not able to make a linebreak.
  • SimonT
    Offline / Send Message
    SimonT interpolator
    Weird!

    .AcceptsReturn: Enter doesn't work, Strg+Enter doesn't work
    .AcceptsTab: Enter doesn't work, Strg+Enter works
  • SimonT
    Offline / Send Message
    SimonT interpolator
    Found the solution:

    1. I had to set AcceptsReturn AND AcceptsTab to true. Only *Return didn't worked
    2. I had to check if Enter was pressed and paste a line break manually

    rollout unnamedRollout "Untitled" width:389 height:279
    (
    dotNetControl textboxctrl "System.Windows.Forms.TextBox" pos:[16,16] width:232 height:200

    on unnamedRollout open do
    (
    textboxctrl.AcceptsReturn = true;
    textboxctrl.AcceptsTab = true;
    textboxctrl.WordWrap = false;
    textboxctrl.Multiline = true;
    textboxctrl.ScrollBars = textboxctrl.ScrollBars.both;
    )

    on textboxctrl keydown pressedKey do
    (
    if (pressedKey.keyvalue == 13) do textboxctrl.paste("\r\n");
    )
    )

    createDialog unnamedRollout;
Sign In or Register to comment.