Scale Edit Box Help

For general discussion related FlowStone
Post Reply
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Scale Edit Box Help

Post by Perfect Human Interface »

I'm trying to make an edit box scale to the width of the module it's in. To do so I simply took the modules width from the MGUI and brought it into the Ruby code block in the edit box (as "mWidth"). You can see how I've made simple changes in the Ruby code to adjust with that variable in two places. One is in drawing the background to the edit box ("def draw"), and one is in scaling the edit/text area ("def viewSize"). The former works fine, but the latter doesn't update as the top-most module is resized. If you resize, then open the Ruby code block and type something in there (like a space), it will update correctly. So what I need to know is how to make this update as the module is resized. Of course, I don't know Ruby very well.

Any help is appreciated!
Attachments
scale edit box.fsm
(1.03 KiB) Downloaded 807 times
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: Scale Edit Box Help

Post by TheOm »

You have to output the new Area when mWidth changes.
Attachments
scale edit box.fsm
(1.07 KiB) Downloaded 787 times
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Scale Edit Box Help

Post by Perfect Human Interface »

Ah ok, I thought it might need to be wrapped into the event method but I wasn't sure how to. So the viewSize method is called in the event block.

Code: Select all

def event i,v
   viewSize(nil, nil, nil, getViewSize(0)[1]) if i == "mWidth"
   redraw 0
end


I didn't understand the arguments at first, but I've figured it out now. The array "a" is being defined without using x,y,or w, so you've just set those to nil. And getViewSize(0) returns an array of width, height of view on input 0, and you've taken just the height value from the array (index 1) as the h argument.

Never would have figured that out on my own. Thanks. :)
Post Reply