Page 1 of 1

Retrieve pnt from contextMenuInput

Posted: 5 Mar 2014 14:04
by hrai36
Hi,

I am very new to visual prolog and want to find out how I can get the X,Y coordinates of
a point from the contextMenuInput.

I am using this in the OnContextMenu event. onContextMenu(_Source, _INP) = window::defaultContextMenuHandling

contextMenuInput =
mouse(vpiDomains::pnt CursorPosition);
keyboard.


I see the point and its X,Y coordinates in the debugger, but I don't know how to extract these from the _INP variable.

Posted: 6 Mar 2014 13:09
by Thomas Linder Puls
You extract/project the sub-values by matching a term containing variables against the value.

Code: Select all

window::mouse(vpiDomains::pnt(X, Y)) = Inp
Here in context:

Code: Select all

predicates     onContextMenu : contextMenuResponder. clauses     onContextMenu(_Source, Inp) = window::defaultContextMenuHandling :-         if window::mouse(vpiDomains::pnt(X, Y)) = Inp then             stdio::writef("Context menu mouse press at X = %, Y = %\n", X, Y)         else             stdio::writef("Context menu invoked by keyboard")         end if.

Posted: 6 Mar 2014 13:40
by hrai36
Thank you. That worked perfectly.