LSL: Popup Dialog

list POPUP_OPTIONS = ['Debug', 'On', 'Off'];
string POPUP_TEXT = "Pop-up dialog box";
integer LISTEN_CHANNEL = -1;
float MENU_TIMEOUT = 30.0;
integer listen_handle;
 
...
 
    touch_start(integer touchNumber) {
        listen_handle = llListen(LISTEN_CHANNEL, "", NULL_KEY, "");
        llDialog(llDetectedKey(0), POPUP_TEXT, POPUP_OPTIONS, LISTEN_CHANNEL);
        llSetTimerEvent(MENU_TIMEOUT);
    }
 
    listen(integer channel, string name, key id, string message) {
        if (channel == LISTEN_CHANNEL) {
            llListenRemove(listen_handle);
            if (message == "Debug") {
                // Debug
            }
            else if (message == "Off") {
                // Off
            }
            else if (message == "On") {
                // On
            }
        }
    }
 
    timer(){
        llListenRemove(listen_handle);
        llSetTimerEvent(0);
    }