//	M550 : Right click and popup menu
define port = 4;

function main()
{
	_Cls();
	_PrintF("Shift / Ctrl + Right-click to display the pop-up menu.\n");
	_PrintF("While the popup menu is displayed, the display of the received text stops.\n");

	_ComCreate	   (port);
	_ComSetOnRxText(port, "OnRxText");
	_ComOpen	   (port, 115200, 8, 0, 1);

	_Stop();

	_ComDelete(port);
}

function _OnRClick(x, y, shift, ctrl)
{
	define	id;
	define	$menu[] = {	"Send text",
						"End"};

	id = _PopupMenu($menu[], x, y);

	if		(id == 0) {					//	- Send text
		_ComSendText(port, $_StrCat($_DateAndTime(), "\n"));
	}
	else if (id == 1) {					//	- End
		_Restart();
	}
}

function  OnRxText($Text)
{
	_PrintF("%s", $Text);
	_PrintF("\n");
}
