Page 1 of 1

New to Ruby.

Posted: Tue Sep 08, 2015 3:10 pm
by primeposition
Create_drop_down_list_1.fsm
(830 Bytes) Downloaded 825 times


Hi All,

Can someone help me, im simply trying to get the index from the selected string to show up on the front panel, How do I get the string to be drawn? May sound silly but I'm struggling to find the answer. I found some information nut I am new.

Thanks.

Re: New to Ruby.

Posted: Tue Sep 08, 2015 3:44 pm
by tulamide
Here you are. And welcome to the forums :)

Re: New to Ruby.

Posted: Tue Sep 08, 2015 4:49 pm
by primeposition
Hi thanks,

How do you make it display the name in string thats coming in on the input?

Thats more what I was getting at? If thats ok?

cheers

Re: New to Ruby.

Posted: Tue Sep 08, 2015 4:57 pm
by tulamide
Here you are. From your description, it wasn't clear: "im simply trying to get the index from the selected string to show up on the front panel, How do I get the string to be drawn?"

Hope it helps!

Re: New to Ruby.

Posted: Tue Sep 08, 2015 5:19 pm
by primeposition
Wow, thats amazing, thank you so much. So I couldent be really cheeky and Get a small explanation so I can get my head round how that's been done? Seen that you used .split and created what looks like a global varible from @index.
But its the event handling im unsure of.

Just so I can learn really.

cheers

Re: New to Ruby.

Posted: Tue Sep 08, 2015 6:22 pm
by tulamide
The "global" variable is a class instance variable (the RubyEdit is just a class as everything in Ruby, see my Ruby Stripped Series on Flowstone GURU)

The event handling is pretty straight forward. You need to tell Flowstone, when to draw the front panel. We know that the selection may have changed after the menu is closed, so this is the spot were we need to draw. When closing the menu, the finished-method is executed, so our code should go there. There's a special Flowstone-specific method called "redraw", that triggers a draw of the front panel, using the code from the draw method. That's it.