Prompting A User For a Canvas Click

Ryan Burnside pixeloutlaw at gmail.com
Mon Dec 7 18:27:19 UTC 2020


[Apologies to the postmaster if this was originally sent via rburnside at fumico.net, please delete that thread. This account is the registered one]

Hello All,

I'm currently caught in a catch22.
I wish to make a CAD like program for diagram drawing.
This means I need to draw lines and boxes and such - stuff Ltk's canvas
is quite capable of.

Here is the kicker, I want to let the user define their own complex
drawing functions which would get sucked up into my Ltk program when it
starts.

The problem is, the minute a user's function gets executed, Ltk would
stop updating.
So, if they had a dynamic user defined function that needed points (as
clicked by the canvas) Ltk would freeze and their user defined function
could not get the points from the interface.

Suppose a user loaded a command like so:
(defun draw-foo (&key (pt1 nil) (pt2 nil))
    (unless (or pt1 pt2)
      (setf pt1 (prompt-canvas "Define point 1 of FOO."))
      (setf pt2 (prompt-canvas "Define point 2 of FOO.")))
    (user-defined-drawing-nonsense pt1 pt2))

We can't hit PROMPT-CANVAS because at that point the program flow is
entered the DRAW-FOO body.
Ltk is great for forms but keeping both Lisp waiting for a value and Ltk
catching events seems very tricky.

Sincerely,
Ryan Burnside (Pixel_Outlaw)




More information about the ltk-user mailing list