Cancel event not emitted on menu dismiss with [config.allowDismissRootMenu = 1]

I had a very long post here and decided to save you all from the ancillary details. short version instead:
if you set the config attribute to allow menus to be dismissed, then you can't KNOW it has happened from your code because the 'cancel' event is not triggered. I'd like to know when this happens...

I'm fiddling around with ways to work around this now, and it seems there are ways to do so - but I suspect the 'cancel' event ought to fire.

I think the reason you’re not getting the “cancel” event is the “confirm” and “cancel” events are superseded by the menu’s own “select” and “dismiss” events.

Can I detect those in my script?

Yes. Menu events are handled by the game object. You can declare event handlers for them and forward them to the player telling it to call its confirm" or cancel handler depending on the event.

1 Like

thanks!
i'm not sure i understand how to accomplish this though?

If I dismiss a menu, would one of the "options" be triggered? I assume from your last comment that I should do something like:

tell event.px,event.py to
    call "cancel"
end

but i don't see where to place that code so it would run when i dismiss a menu... is there an interface like this perhaps?

menu at x,y,len,items then
    option "optionOne" then
        // do one thing
    end
    option "optionTwo" then
        // do another
    end
    dismiss then
        tell event.px,event.py to
            call "cancel"
        end
    end
end

No, dismiss means you’ve closed the menu without selecting an option. In your game's PulpScript:

on dismiss do
  tell event.player to
    call "cancel"
  end
end

This bit of the docs is probably of interest to you:

select: called on the game when the player selects an option in a menu or ask menu
dismiss: called on the game when the player dismisses a menu submenu
invalid: called on the game when the player attempts to back out of a menu or selects an empty option

1 Like

Thanks @shaun !

dismiss
It sounds like I could rework my menus to use this, but I'd still have a raft of custom code underneath to handle things so my players can interact with multiple menu items and have them update while the menu is open.
Oh well - thanks anyway :slight_smile:

select
This is interesting, but only triggers when the user actually taps the A button on a selection, yeah? This is getting a lot closer to something I could use! I'd love to have the menu emit an event when the user moves the cursor around, not just when they tap the A button.

See this GIF as an example usecase where it would be useful to update some variables for the description of the menu item currently pointed at by the cursor.
emotive-edit-menu

NOTE: I'm currently executing a SAY command in the submenu that's inverted. This is problematic for several reasons - some you can see in the GIF and others come later (e.g. the SAY window persists after dismissing the menu, so players have to press an extra button to be rid of it before playing again)

I'd prefer to render LABEL commands that same space and have the label change whenever the player moves the cursor - i would use the same in-game documentation for both of the menus shown in the animation.

Also, it would be REALLY useful if LABEL, SAY, etc could understand '\n'. For now the lack of newlines in a string makes the SAY command at least a little more functional for me.

Sorry I dropped the ball on this thread! I think you want the change event:

change: called on the game when the cursor moves to a different option in a menu or ask menu and when the menu first appears

1 Like