Message sent when object placed onto card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Message sent when object placed onto card
If you're using drag/drop handlers you can get info about the object when it's dropped and send a custom message from there. In a dragDrop handler, get the dragData and act on it. See the last paragraph in the dragdrop dictionary entry.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Yes Craig, you are exactly right. I'm developing a tutorial stack and it's participatory... the user gets to add objects to the cards. Sometimes I would like to augment the controls functionality by adding a script to it. While it's not impossible to manage this without having a message sent when the user adds a control, it would HUGELY simplify my task if I knew when objects are being added. But I've found ways to work around this limitation so all is good for now. Would it be of some use to others to have a feature like that (ie. a message sent to the card in pointer mode when a control is added)? If so I don't mind making a feature request.
Best,
Mark
Last edited by marksmithhfx on Sun Mar 19, 2023 9:39 pm, edited 2 times in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Yes Jacque, there is a drag and drop involved. A picture being worth a thousand words I've included two. As you can see there is table of SQL column attributes on the right. The user is instructed to drag a polygrid onto the card and then populate it with columns by dragging objects from the SQL attributes table to the PG. This all works really well. My drop code is in the card so the populating of columns does not require any PG handler. However, the last part of the instruction "Click on a PolyGrid row to edit the record" does. The 2nd image demonstrates what this looks like, and its handled by adding this code to the PG.
Code: Select all
on cellClick pColumnNumber, pRowNumber, pCellRect
set the pgInternalPointer of me to pRowNumber
put the pgDataOfRow of me into lmyArray
set the dialogData to lmyArray
set the visible of stack "Edit User" to true
modal stack "Edit User"
-- on return...
if the dialogData is not empty then
put the dialogdata into lmyArray
set the pgDataOfRow of me to dialogData
updateSQLrecord
end if
end cellClick
the piggy back happens here... (note this is a pretty custom drag drop handler which depends on mousemove and intersect to determine when the "field" control (created by dragging something out of the table) is over the PG. You can see where I've decided to update the PG script (and its ok there because there is nothing to click on until at least one column of data has been added).
Code: Select all
else -- field is dropped
if exists (card widget 1) then
put the short name of widget 1 into tWidgetName
get the pgBorderColor of widget tWidgetName
if it is "0,255,0,255" then -- green with an extra 255 tacked on
set the pgBorderColor of widget tWidgetName to black
put the text of gMyNewControl into tColumnName
addColumn2PolyGrid tWidgetName, tColumnName
end if
end if -- if exists
delete gMyNewControl
put false into gHaveNewControl
focus on nothing
-- oh, and by the way, lets update the PG script while we are it.
put the script of widget tWidgetName into tTest
if tTest is empty then
set the script of widget tWidgetName to the cScript37 of cd "Home"
end if
end if -- mouse is down
end if -- have new control
end mousemove
mark
Image 1 https://www.dropbox.com/s/8meio7pdi0tv8 ... 1.png?dl=0
Image 2 https://www.dropbox.com/s/mnqwsj6lxthck ... 2.png?dl=0
PS increasing image size to 50% improves clarity and readability.
Last edited by marksmithhfx on Sun Mar 19, 2023 8:59 pm, edited 2 times in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- Livecode Opensource Backer
- Posts: 10097
- Joined: Fri Feb 19, 2010 10:17 am
Re: Message sent when object placed onto card
That's a funny way of including images.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Yeah, I couldn't remember the name of the img url website, so improvised

macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: Message sent when object placed onto card
Mark.
If you make a new control by any other method than dragging from the tools palette, the messages are sent. So if you are building a standalone app, you will always want to have some other action do that; users do not see the tools palette, so that limitation is IDE-only.
Craig
If you make a new control by any other method than dragging from the tools palette, the messages are sent. So if you are building a standalone app, you will always want to have some other action do that; users do not see the tools palette, so that limitation is IDE-only.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Thanks Craig, noted. For the time being this demo stack is going to be limited to the IDE. If not the least because it is self-modifying and many cards are generated on the fly... I'm not sure if standalones are allowed to do that? Or is it just standalones distributed through the App Store that are constrained by that limitation?dunbarx wrote: ↑Sun Mar 19, 2023 9:21 pmMark.
If you make a new control by any other method than dragging from the tools palette, the messages are sent. So if you are building a standalone app, you will always want to have some other action do that; users do not see the tools palette, so that limitation is IDE-only.
Craig
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: Message sent when object placed onto card
Standalone can do anything the IDE can.
Craig
Craig
-
- Posts: 101
- Joined: Mon Jan 03, 2022 7:10 pm
Re: Message sent when object placed onto card
If the stack is your standalone application, you won't be able to save the changes. But you can create a stack and save that with the changes and new cards.marksmithhfx wrote: ↑Sun Mar 19, 2023 9:35 pmIf not the least because it is self-modifying and many cards are generated on the fly
Re: Message sent when object placed onto card
Mark.
Emily is talking about the "Splash Stack" method, well discussed in this forum. It is what I do.
The only other way is to use external files.
Craig
Emily is talking about the "Splash Stack" method, well discussed in this forum. It is what I do.
The only other way is to use external files.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Thanks for that reminder Emily. I don't often use that technique but you are correct, creating a splash stack and then launching/creating other stacks from there would make them modifiable. I probably won't be turning this into a standalone (but as an exercise I might try just to see what changes, if any, are required). Just thinking about it, for one, I would lose access to the tool palette and this demo is about how we go about creating stacks in the first place so I think having the palette there is a necessary part of the demonstration. I'm building a stack to demo some ideas of how LC might go low code/no code (in some limited circumstances). The audience for this is obviously quite small although I'll probably ask a few people here to test it before it goes anywhere (I'm not necessarily any good at catching my own mistakes).Emily-Elizabeth wrote: ↑Mon Mar 20, 2023 2:36 amIf the stack is your standalone application, you won't be able to save the changes. But you can create a stack and save that with the changes and new cards.
Best, and thanks again for the reminder.
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- Livecode Opensource Backer
- Posts: 10097
- Joined: Fri Feb 19, 2010 10:17 am
Re: Message sent when object placed onto card
Mark; can you please post your images inwith the body of a message as . . . .
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Hi Richmond,richmond62 wrote: ↑Mon Mar 20, 2023 11:06 amMark; can you please post your images inwith the body of a message as . . . .
Sorry about that, when I tested after posting them they just popped open for me so maybe that had something to do with them being in my own dropbox acct. Generally my images are too big to post here (these 2 are about .5 - 1.0 MB in size). I've moved them to postImages so please give the following a try and let me know if you are still having difficulty. Honestly, I wish I knew a better way to do this, but this is the best I've been able to come up with.
Thanks,
Mark
Image 1 https://postimg.cc/8fj8TB9K
Image 2 https://postimg.cc/c6HG70CR
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: Message sent when object placed onto card
I did not have any problems downloading and opening the images from your Dropbox on my Mac!?
I opened them in PREVIEW and saved as JPG, so the filesize went down.
I opened them in PREVIEW and saved as JPG, so the filesize went down.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Remarkable. Did you use "Export..." (my Preview doesn't have a Save As... option) and what settings did you use? I could'nt get the images anywhere near that small (28k) in Preview (about 380k was the smallest I could make them with any decent resolution... yours are crystal clear

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS