prev | index | next

MX2004-ContextMenu2
7
30
608 bytes
1361 bytes
2003-09-16 00:00:00
2003-09-21 14:37:06
Oldes (oliva.david@seznam.cz)


How to control the Context menu

In this example, the specified event handler, menuHandler, enables or disables a custom menu item (using the ContextMenu.customItems array) based on the value of a Boolean variable named showItem. If false, the custom menu item is disabled; otherwise, it’s enabled.

make ContextMenuItem [caption callbackFunction separatorBefore enabled visible]

(mx2004-contextmenu2.rswf)
include %includes/txt_info.rswf
doAction [
    info: "Use right mouse button to open the Context menu"
    showItem: true
    menuHandler: func[obj menuObj /local tmp][
        info: "menuHandler"
        tmp: menuObj.customItems/1
        either showItem = false [
            tmp.enabled: false
        ][  tmp.enabled: true ]
    ]
    itemHandler: func[obj item][
        info: "item " add item.caption add " from " add obj
    ]
    my_cm: make ContextMenu [menuHandler]
    with my_cm.builtInItems [
        print: quality: false
        ;save: true
        ;zoom: true
        ;play: true
        ;loop: true
        ;rewind: true
        ;forward_back: true
    ]
    my_cm.customItems.push((make ContextMenuItem ["Hello" itemHandler]))
    my_cm.customItems.push((make ContextMenuItem ["World" itemHandler true]))
    _root.menu: my_cm
]

ShowFrame
end