Discussions related to Visual Prolog
hrai36
Posts: 4
Joined: 5 Mar 2014 13:50

Retrieve pnt from contextMenuInput

Unread post 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.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
hrai36
Posts: 4
Joined: 5 Mar 2014 13:50

Unread post by hrai36 »

Thank you. That worked perfectly.
Post Reply