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
backgroundbackground colour cannot be changed
different behaviour
sizegadget height is fixed and look-and-feel dependant. for aqua (os x) the height is around 26px including focus border
alignmenttext is left aligned, not centered
extended functionality
allowsReselectioncan be set to 'true' to trigger action even if the user selects the same item again
known issues / todo
drag-n-dropdrag gesture not yet recognized
backgroundcannot 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 baropen menu (look-and-feel dependant)
csr up/downopen menu and scroll (look-and-feel dependant)
returnchoose selected item (look-and-feel dependant)
csr left/rightdecrease/increase selected item