Prompting A User For a Canvas Click

cage cage-dev at twistfold.it
Wed Dec 9 12:52:12 UTC 2020


On Tue, Dec 08, 2020 at 08:38:36PM +0100, cage wrote:

Hi!

By the way does this code works as you wanted in you message?

I am using nodgui because includes a modal inputbox but could be easily
translated to LTK.

---8<-------8<-------8<---------

(in-package :nodgui)

(defun ask-point (title message)
  (parse-integer (nodgui.mw:text-input-dialog *tk* title message)))

(defun draw-line (canvas)
  (let ((x1 (ask-point "point?" "x1?"))
        (x2 (ask-point "point?" "x2?"))
        (y  (/ (canvas-h canvas) 2)))
    (make-line canvas (list x1 y x2 y))))

(with-nodgui ()
  (let ((canvas (make-canvas nil :width 300 :height 300)))
    (configure canvas :background "#FFFFFF")
    (pack canvas)
    (draw-line canvas)))

---8<-------8<-------8<---------

The code above is licensed FWIW with MIT license
https://opensource.org/licenses/MIT

bye!
C.



More information about the ltk-user mailing list