Today we’ll create a hyperlink cell in the MPS editor that will open a URL in the browser when clicked:

The final result

The link cell is in fact a customized constant cell. We need to modify two things: make the cell clickable, and make it blue and underlined. To make a cell clickable I use a cell action map and define a handler for the CLICK action:

Action map with CLICK action handler

We use the standard Desktop#browse(URI) Java API to open the URL in a browser. In case of an error we show the error message using a notification balloon rather than a message box, as explained in yesterday’s post.

Now we only need to tell MPS to use this action map for our cell, and style the cell to appear blue and underlined:

Link cell definition

And again, this is the final result:

The final result, again