Replies: 3 comments
-
First of all, I don't do a lot of web programming so my terminology is probably incorrect. That being said, I believe what is happening is that when you call:
four times (one for each item-drop-0n), you are actually adding four handlers to target. Then when an item is dropped onto target, it calls all four of these handlers. You can verify this by replacing your
forms with something like:
Also, replace
with
Now when you drop an item on target, you'll see that four messages get dumped and they all print out the same number (the number of the item you dragged). For example, if you drop "object 01" onto the target, you should see:
This implies that all four target handlers are being called with the same item that you dropped onto it. However, each target handler also calls place-inside-bottom-of with item-drop-0n (for n = 1..4). These handlers get called in order so item-drop-01 gets placed first inside target. Then item-drop-02 replaces item-drop-01 in target. Then item-drop-03 replaces item-drop-02 in target. And finally item-drop-04 replaces item-drop-03 in target. So every time you drop an item, you see item-drop-04 in target. To fix this, I deleted all the
sections of code. Then I added one target handler like this:
Lots of code duplication in that handler but it worked for me. |
Beta Was this translation helpful? Give feedback.
-
Hi! Oh wow. Thank you very kindly for spending time on my nonsense question. This has helped me tremendously. Details:
Learning about (let) vs (let*), lexical scope, bindings and so forth have been fun puzzles. I am still reading forms wrong and make assumptions based on that reading. This illustration really helps with that.
Lisp is fun and CLOG is just the kind of hook that I needed to get me really interested in pushing and learning. Appreciate the amazing help. |
Beta Was this translation helpful? Give feedback.
-
I created a version of the app with 3 drag targets. I suspect I will be able to compress the code once I learn about object orientation, for now this is just to demonstrate basic CLOG drag/drop functionality. Video of functionality: demo-2023-08-17_03.56.08.mp4Note: The repo with the sample code is deleted. For anyone looking for an example of working code it is pasted here. Code for the demo in the video:
|
Beta Was this translation helpful? Give feedback.
-
Rabbi Botton:
QUESTION: The form (set-on-drop) does not seem to follow lexical binding. Instead, it is always bound to the last object that (set-on-drop) refers to.
I have created the simplest possible todo widget to demonstrate the (set-on-drop) behaviour here: https://github.com/aykaramba/todo-04
Each object has its "draggablep" property set correctly.
Each object has a (set-on-click) lexicaly bound and the (place-inside-bottom-of target item-***) works properly.
ONLY the (set-on-drop) form seems to either ignore the lexical binding or the form behaviour is something other than what I am expecting.
Here is a video of the (set-on-click) form properly doing (place-inside-bottom-of) form behaviour, whereas the (set-on-drop) form is only doing (place-inside-bottom-of) form behaviour on the last object it was bound to:
simplescreenrecorder-2023-08-06_18.27.46.mp4
Thoughts?
Code: https://github.com/aykaramba/todo-04/blob/main/todo-04.lisp
Beta Was this translation helpful? Give feedback.
All reactions