Closed ghost closed 6 months ago
Since commit https://github.com/trustable-code/NiGui/commit/3cd60917d261942dff845b3fd7c6fe81ccb82c48 there are methods to retrieve the mouse cusor position relative the window or the widget.
Example program:
import nigui
app.init()
var window = newWindow()
var mainContainer = newContainer()
window.add(mainContainer)
var button = newButton()
mainContainer.add(button)
button.width = 300
button.height = 150
button.x = 150
button.y = 150
window.show()
proc timerProc(event: TimerEvent) =
var text = ""
block:
var (x, y) = window.mousePosition()
text.add($x & ", " & $y)
text.add(" | ")
block:
var (x, y) = button.mousePosition()
text.add($x & ", " & $y)
button.text = text
let timer = startRepeatingTimer(50, timerProc)
app.run()
Looks like resolved to me.
Hi, I was wondering if it's possible to obtain the position of the cursor from a clickevent. Is there something like a
cursor
field? Thex
andy
fields respectively only seem to return the position of the widget.