Here we have two independent menus "Menu1" and "Menu2". Method
make_menu1(title, left, top, width, items, orientation, clickk, leavee)
takes 8 arguments:
- title - title of the menu (string)
- top, left - coordinates of the left upper corner (in pixels) of the menu title in the current slot
- width - width of the menu (in pixels)
- items - array of items (strings) to be displayed when menu pop-ups
- orientation - should menu open horizontally (:hor) or vertically (:ver)
- clickk - sholud menu open upon clicking the menu title (true) or by hoovering over it (false)
- leavee - should menu close after mouse leaves the menu area (:leave_of) or should it stays on (:leave_on)
Now if we click any item the method returns the item clicked and we can use it for any furhter action, e.g. like here:
make_menu("Menu2",80, 130, 70, items1, :ver, true, :leave_on){|x| alert "You clicked: #{x}"}
where the alert will be shown with the information on the item clicked :
It is very simple and easy to modify so that one could set up colors as well etc.
The code can be found here.
Hope you will have fun with it.
2 comments:
Hi and thank you for the menu code. With Shoes r0.970 under XP Pro and rapid mouse movement the internal state of the menu gets confused. I have attempted to put a monitor around the make_menu body to see if it is a reentrancy problem but to no avail.
Thanks I know but it general problem with "hover" on Shoes. You cannot be too quick :)
Post a Comment