How to resolve the algorithm Mouse position step by step in the Oz programming language

Published on 12 May 2024 09:40 PM
#Oz

How to resolve the algorithm Mouse position step by step in the Oz programming language

Table of Contents

Problem Statement

Get the current location of the mouse cursor relative to the active window. Please specify if the window may be externally created.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Mouse position step by step in the Oz programming language

Source code in the oz programming language

declare
  [QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
  WindowClosed = {NewCell false}
  Label
  Window = {QTk.build
	    td(action:proc {$} WindowClosed := true {Window close} end
	       label(text:"" handle:Label))}
in
  {Window show}

  for while:{Not @WindowClosed} do
     TopmostWindow = {List.last {String.tokens {Tk.return wm(stackorder '.')} & }}
     Winfo = {Record.mapInd winfo(rootx:_ rooty:_ pointerx:_ pointery:_)
	      fun {$ I _}  
		 {Tk.returnInt winfo(I TopmostWindow)}  
	      end}
  in
     {Label set(text:"x: "#(Winfo.pointerx - Winfo.rootx)
		#", y: "#(Winfo.pointery - Winfo.rooty))}
     {Delay 250}
  end

  

You may also check:How to resolve the algorithm Man or boy test step by step in the PL/I programming language
You may also check:How to resolve the algorithm Selectively replace multiple instances of a character within a string step by step in the RPL programming language
You may also check:How to resolve the algorithm Roots of a quadratic function step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Chinese zodiac step by step in the Java programming language
You may also check:How to resolve the algorithm Deceptive numbers step by step in the Lua programming language