RosettaCodeData/Task/Mouse-position/Nim/mouse-position.nim

26 lines
642 B
Nim
Raw Permalink Normal View History

2025-02-27 18:35:13 -05:00
import gtk2, glib2
import gdk2 except PWindow
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
proc onButtonPress(window: pointer; event: PEventButton; data: pointer): gboolean {.cdecl.} =
echo event.x, " ", event.y
result = false
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
proc onDestroyEvent(widget: PWidget; data: pointer): gboolean {.cdecl.} =
## Quit the application.
mainQuit()
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
nimInit()
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
let window = windowNew(WINDOW_TOPLEVEL)
window.setTitle("Mouse position")
window.setSizeRequest(640, 480)
window.setEvents(BUTTON_PRESS_MASK)
discard window.signalConnect("destroy", SIGNAL_FUNC(onDestroyEvent), nil)
discard window.signalConnect("button-press-event", SIGNAL_FUNC(onButtonPress), nil)
window.showAll()
2023-07-01 11:58:00 -04:00
2025-02-27 18:35:13 -05:00
main()