If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Scale Edit Box Help
3 posts
• Page 1 of 1
Scale Edit Box Help
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!
Any help is appreciated!
- Attachments
-
- scale edit box.fsm
- (1.03 KiB) Downloaded 741 times
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
Re: Scale Edit Box Help
You have to output the new Area when mWidth changes.
- Attachments
-
- scale edit box.fsm
- (1.07 KiB) Downloaded 720 times
- TheOm
- Posts: 103
- Joined: Tue Jan 28, 2014 7:35 pm
- Location: Germany
Re: Scale Edit Box Help
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.
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.
- 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.
- Perfect Human Interface
- Posts: 643
- Joined: Sun Mar 10, 2013 7:32 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 74 guests