News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
multiple menu bar issue
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: multiple menu bar issue

I've come up with a sloppy workaround, which I haven't fully explored but it does prevent the troubles I was having. It consists of using either a hidden menu that supplies menu items for all visible menus, or using one of the visible menus to supply menu items for all other menus. The second option could potentially become very sloppy, since items not intended to be seen on that main menu must be hidden. This could easily result in losing track of what items you have, and where they are.

The process goes something like this....

Code:
function menu_callback()
if menu2:text()=="&disable item3" then toggle_item:deactivate()
elseif menu2:text()=="&enable item3" then toggle_item:activate()
end
menu1:redraw()
end

window = fltk:Fl_Window(400, 200, "menu test")
main_menu=fltk:Fl_Menu_Button(0,0,0,0) -- essentially invisible
menu1=fltk:Fl_Menu_Bar(0,0,400,30)
menu2=fltk:Fl_Menu_Bar(0,40,400,30)

main_menu:add("menu1/item1")
main_menu:add("menu1/item2")
main_menu:add("menu1/item3/item3a")
main_menu:add("menu1/item3/item3b")
main_menu:add("menu1/item4")
main_menu:add("menu2/&File/item5")
main_menu:add("menu2/&File/item6")
main_menu:add("menu2/&File/item7")
main_menu:add("menu2/&File/&enable item3")
main_menu:add("menu2/&File/&disable item3")

-- create pointers to the first items in each submenu
-- this will allow menu() to grab all items on or below that level
menu1menu=main_menu:find_item("menu1/item1")
menu2menu=main_menu:find_item("menu2/&File")
menu1:menu(menu1menu)
menu2:menu(menu2menu)

toggle_item=menu1:find_item("item3") --create a pointer to menu1/item3

menu2:callback(menu_callback)

window:show()
Fl:run()


Important note: using "add()" on menu1 or menu2 after this point may cause a segfault, and adding to main_menu can cause an unwanted shift to the other menus, so apparently this is still not a solution for dynamically changing the number of menu items available.

Again, this is a workaround for something I don't fully understand, and should not to be considered the recommended method.

This post was last modified: 08-18-2007 02:00 AM by mikshaw.

08-18-2007 01:45 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
multiple menu bar issue - mikshaw - 08-03-2007, 11:54 AM
RE: multiple menu bar issue - mikshaw - 08-18-2007 01:45 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: