Prompting A User For a Canvas Click
Ryan Burnside
pixeloutlaw at gmail.com
Wed Dec 9 22:38:03 UTC 2020
Hello cage,
Thanks for the reply.
Your code did demonstrate the general idea if I was collecting from a field.
But as this is a CAD program (think drafting) it's important that the
user be able to pick points of interest from a main canvas.
As important that the canvas cursor can "snap" to points of interest
such as endpoints intersections etc. (I'll handle that myself).
Here is a diagram if it helps...
https://i.imgur.com/5uxY7Tq.png
Hopefully this is possible!
The with-ltk macro and single thread seem to fight against updating
ltk's widgets explicitly while collecting input.
Sincerely,
Ryan Burnside
On 12/9/2020 5:52 AM, cage wrote:
> 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