It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I observe what I think is a small bug. In general this bug isn't a showstopper, but it does lead to an idea for a feature (see end of post).
Steps to reproduce the problem:
So, it works the second time.
I tried pasting the same code twice serially, and running it, but it doesn't fix the problem.
include RBA
app = Application.instance
mw = app.main_window
menu = mw.menu
icon = File.expand_path('path/to/image.png')
a = Action.new
a.title = "An action"
root = "@toolbar."
if !menu.is_menu?(root + "parent_menu") # If it doesn't already exist, create it
menu.insert_menu(root + "end","parent_menu","Parent menu")
p 'inserting parent menu'
end
if !menu.is_menu?(root + "parent_menu.child_menu") # If it doesn't already exist, create it
menu.insert_menu(root + "parent_menu.end","child_menu","Child menu")
p 'inserting child menu'
end
if !menu.is_valid?(root + "parent_menu.child_menu.an_action") # If it doesn't already exist, create it
menu.insert_item(root + "parent_menu.child_menu.end","an_action",a)
p 'inserting action'
end
# Assign the same icon to all three.
# Icon attaches successfully for Parent menu and Action, but not for Child menu
menu.action(root + "parent_menu").icon = icon
menu.action(root + "parent_menu.child_menu").icon = icon
menu.action(root + "parent_menu.child_menu.an_action").icon = icon
I suppose it would be nice to have, on some future version of KL, an option to choose the icon in the .lym Properties window, and it would be stored in the XML metadata -- which would be nice but also fix the problem.
Thanks,
David
Comments
Hi David,
thanks for mentioning this. I simply didn't have icon assignment for menus on my screen.
I was able to fix that issue, except when you try to create a top-level menu with an icon: apparently Qt does not like menu bar entries with an icon. There is an icon now, but it looks pretty ugly.
Thanks,
Matthias