Context menu
#1
Hello,

I am trying to display context menu (when you press C or right mouse) only on items from database. So I am using conditional visibility.

I.e. under "pictures" i have my database of pictures (Photos) and 2 more thumbs - "Picture Addons" and "Add Pictures...". My goal is to display addon menu only for items from database, not these Kodi buttons.

In addon.xml I have like:

Code:
<extension point="kodi.context.item">
        <menu id="kodi.core.main">
            <menu>
                <label>Main menu</label>
                <item library="menu_1.py">
                    <label>Menu1</label>
                    <visible>Window.IsActive(10002) + Window.IsMedia + ListItem.IsFolder</visible>
                </item>
                <item library="menu_2.py">
                    <label>Menu2</label>
                    <visible>Window.IsActive(10002) + Window.IsMedia + ListItem.IsFolder</visible>
                </item>
            </menu>
        </menu>
    </extension>

My code checks if the window is Window.IsActive(10002) - pictures and if it has media and if it is Folder... but the MENU is still displayed for "Picture Addons" and "Add Pictures..." - where it is useless because these are not folders or database items.

I tried by checking "Container.FolderPath" , "ListItem.Label " etc checking with "String.IsEqual" etc but nothing seems to work. In Python script, I am able to get ListItem.Label for these items, but not from addon.xml...

Any clue how to prevent my submenu displaying for this 2 items?

Thanx!
D.
Reply
#2
try adding "!String.IsEmpty(ListItem.FolderName)" to the visible condition.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Nope, still there....

Also, is there a way to put condition on the 1st level menu, not SUB-menues?

I.e.

<extension point="kodi.context.item">
<menu id="kodi.core.main">
<menu>
<label>Main menu</label>
<visible>Window.IsActive(10002) + Window.IsMedia + ListItem.IsFolder</visible>
<item library="menu_1.py">
<label>Menu1</label>
<visible>Window.IsActive(10002) + Window.IsMedia + ListItem.IsFolder</visible>
</item>
<item library="menu_2.py">
<label>Menu2</label>
<visible>Window.IsActive(10002) + Window.IsMedia + ListItem.IsFolder</visible>
</item>
</menu>
</menu>
</extension>
Reply
#4
Fist of all, never use Window or Container in a visibility condition. This will cause your addon randomly 'break' depending on where in kodi that item happened to be shown.

Your menus are shown for "Picture Addons" and "Add Pictures..." because those are folders too; virtual folders. So try finding some property from http://kodi.wiki/view/InfoLabels#ListItem that only pictures have. Maybe ListItem.PicturePath will work?
Reply
#5
How am I to make sure it works in pctures only w/o Window? PicturePath shows up alson in music.... strange. Also, I am not looking for PICTURES as such, but FOLDERS in PICTURES. So picture propertes such in EXIF tags wouldn't work since FOLDERS don't have EXIF info.

Anyway, is there a way to set the visibility condition for the ROOT menu - <label>Main menu</label> ?
Reply
#6
You can't, by design. The visibility of <menu> is determined by the combined visibility of its items.
Reply
#7
So if none of the items are visible, the main menu will be invisible too? OK, that's acceptable for my purpose Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Context menu0