Custom Window: Open Context Menu on List
#1
Information 
I created a custom WindowXMLDialog for my addon. The window has a list:

xml:
<?xml version="1.0" encoding="UTF-8"?>
<window>
    <views>50</views>
    <coordinates>
        <left>0</left>
        <top>0</top>
    </coordinates>
    <controls>

        <control type="group">

            <control type="list" id="50">
                <description>Stream List</description>
                <left>0</left>
                <top>0</top>
                <width>1000</width>
                <height>500</height>
                <visible>true</visible>
                <viewtype label="535">list</viewtype>
                <pagecontrol>95060</pagecontrol>
                <orientation>vertical</orientation>
                <scrolltime tween="sine">200</scrolltime>
                <autoscroll>false</autoscroll>
                <onleft>SetFocus(9050)</onleft>
                <onup>50</onup>
                <ondown>50</ondown>

                <itemlayout width="500" height="100">
                    <control type="label">
                        <left>0</left>
                        <top>0</top>
                        <width>500</width>
                        <height>100</height>
                        <font>font13</font>
                        <aligny>center</aligny>
                        <selectedcolor>green</selectedcolor>
                        <align>left</align>
                        <info>ListItem.Label</info>
                    </control>
                </itemlayout>
                
                <focusedlayout width="500" height="100">
                    <control type="label">
                        <left>0</left>
                        <top>0</top>
                        <width>500</width>
                        <height>100</height>
                        <font>font13</font>
                        <aligny>center</aligny>
                        <selectedcolor>green</selectedcolor>
                        <align>left</align>
                        <info>ListItem.Label</info>
                    </control>
                </focusedlayout>
            </control>
        </control>

    </controls>
</window>

I then create an instance from this window in Python and dynamically add items to the list:

python:
# Start in a separate thread
win = xbmcgui.WindowXMLDialog('mywindow.xml', addonPath(), 'default', '720p')
win.doModal()

# Add items in main thread after launching the custom window
item = xbmcgui.ListItem(label = label)
  # set some properties on the list item.

# Create context menu
contextMenu =
ontextMenu.append(('Action 1', 'command1')
ontextMenu.append(('Action 2', 'command2')
item.addContextMenuItems(contextMenu)

# Add list item to window
win.WindowStreams.getControl(50).addItem(item)

The window launches and populates the list. However when trying to open the context menu on the list item (pressing 'c' or right-click), nothing happens.
When I manually launch the context menu from the window:

python:
ActivateWindow(contextmenu)

then the context menu shows, but it is empty. When I create the list with addDirectoryItem in Pyothn, the context menu works as intended, so my context menu code is correct. Only when trying to launch it from the custom WindowXMLDialog, does the menu not work. Any suggestions on what I'm doing wrong??
Reply

Logout Mark Read Team Forum Stats Members Help
Custom Window: Open Context Menu on List0