Universal Inventory - creating a pop-up when clicking an item

Twine Version: Sugarcube 2.36.1

I’ve just installed the Universal Inventory code from @HiEv - looks amazing! So far I’ve managed to display a table and add a simple item successfully. The inventory display in this game is going to be very simple - I don’t need to use drag/drop functionality or anything.

How can I add an event handler that will open a pop-up dialogue box when an item is clicked/tapped? I just want to display a simple close-up image of each item using the Dialog function to display a passage like this:

1 Like

If I understand correctly what you want, you can put your <<script>><</script>> inside a <<link>><</link>> or a <<button>><</button>>.


Chapel has a “popover” macro, or I believe there’s other ways to invoke a modal window?

1 Like

How are you currently displaying the bag contents? Are you using one of the built in functions?

1 Like

Thank you for your help everyone - sorry I might have been unclear. I am able to display a pop-up just fine, using a link function to show script like in my example above attached to a button, or text, etc.

I have done the following: using the Universal Inventory system, I have been able to make a bag, make an item, put the item in the bag, and display it using techniques from the examples:


What I need to know is: how can I make it possible to launch some <<script>> by clicking on an item in this window? In the examples, they can be dragged, dropped, moved around, etc. I don’t even need that functionality - I would just like to have some code attached to the item that will trigger when it is clicked.

1 Like

Another potential option would be slideWin. It just takes an existing passage as a argument and ‘slides’ it into view over the existing passage. When the player is done they can just close the slideWin window and continue on their way. I use slideWin along with liveupdate to make interactive popups that affect the passage that called them immediately.

To answer your actual question would probably take a little more info than what you have provided.

  1. Where did you get the menu that allows ‘dragged, dropped, moved around, etc’?
  2. Also have you modified it in any way?
  3. Probably something else I haven’t thought of
1 Like