## SwingOSC – Java-based GUI classes

This class is meant as an emulation of SCPopUpMenu. last mod: 17-jul-09 sciss
Also refer to JSCView for different behaviour affecting all widgets

no-op / not working
background | background colour cannot be changed
different behaviour
size | gadget height is fixed and look-and-feel dependant. for aqua (os x) the height is around 26px including focus border
alignment | text is left aligned, not centered
extended functionality
allowsReselection | can be set to 'true' to trigger action even if the user selects the same item again
known issues / todo
drag-n-drop | drag gesture not yet recognized
background | cannot be made transparent since it introduces drawing glitches in the menu (with apple's vm) - the background colour is used also for the menu. default background is therefore not Color.clear

# JSCPopUpMenu

Note: please use the abstraction layer PopUpMenu if possible!

A button element to which a list of items is attached. The item list gets pop'ed up when you click on the button. The currently selected item is displayed in the button.

    (
        var items;
        w = JSCWindow( "JSCPopUpMenu", Rect( 200, 200, 200, 50 ), resizable: false );
        items = [
            "left view", "left thinking", "left mindfulness", "left speech",
            "left action", "left diligence", "left concentration", "left livelihood"
        ];
        m = JSCPopUpMenu( w, Rect( 10, 10, 180, 26 ));
        m.items = items;
        m.action = { arg butt;
            // .value returns the index (integer) of the currently selected item
            [ butt.value, butt.items.at( butt.value )].postcs;
        };
        w.front;
    )

You will notice that the action is not called if the user re-selects the same item. You can change this behaviour by setting `allowsReselection` to `true` (works only in SwingOSC!):

    m.allowsReselection = true;

### default keyboard mappings

`space bar` | open menu (look-and-feel dependant)
`csr up/down` | open menu and scroll (look-and-feel dependant)
`return` | choose selected item (look-and-feel dependant)
`csr left/right` | decrease/increase selected item