Small bug in icon assignment

edited June 2015 in Ruby Scripting

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:

  1. Start KL 0.42-python-eval on Win 8.1
  2. Run the script below once as-is. You will observe that Parent menu and Action have icons, but Child menu does not.
  3. Without changing anything, run the script below a second time. You will observe that all three now have icons.
  4. Further strangeness: again start KL. Run the script below once, but change root to be an empty string "". You will observe Parent and Child do not have icons, but Action does.
  5. Without changing anything, run the script below a second time. You will observe that all three now have icons.

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

  • edited November -1

    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

Sign In or Register to comment.