Message sent when object placed onto card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 939
- Joined: Thu Nov 13, 2008 6:48 am
Message sent when object placed onto card
Hello,
Is a message sent to the card when an object is placed on the card? Like when a new field or button is added? I need to grab the object ID of the newly added object.
Thanks
M
Is a message sent to the card when an object is placed on the card? Like when a new field or button is added? I need to grab the object ID of the newly added object.
Thanks
M
macOS 15.6 (Sequola), Xcode 15.3, LC 10.0.2, iOS 18.6.2
-
richmond62
- Livecode Opensource Backer

- Posts: 10415
- Joined: Fri Feb 19, 2010 10:17 am
Re: Message sent when object placed onto card
NO, no message is sent.
BUT, if you do this:
you will get what you need. 
BUT, if you do this:
Code: Select all
put the id of the last controlRe: Message sent when object placed onto card
The message(s):
newcard
newbutton
newfield
etc.
is/are sent to the newly created object, so you could "catch" that in your card script.
newcard
newbutton
newfield
etc.
is/are sent to the newly created object, so you could "catch" that in your card script.
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 939
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
You guys are a great tag team 
on newWidget
put the id of the last control into NewWidgetID
end newWidget
should be just the fix I was looking for!!
Thank you!
on newWidget
put the id of the last control into NewWidgetID
end newWidget
should be just the fix I was looking for!!
Thank you!
macOS 15.6 (Sequola), Xcode 15.3, LC 10.0.2, iOS 18.6.2
Re: Message sent when object placed onto card
There are at least a dozen "new..." messages sent whenever anything, er, new is created. They are invaluable. Look up "new" in the dictionary for a complete list.
Craig
Craig
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 939
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Thanks Craig.dunbarx wrote: Mon Mar 13, 2023 3:49 pm There are at least a dozen "new..." messages sent whenever anything, er, new is created. They are invaluable. Look up "new" in the dictionary for a complete list.
Craig
macOS 15.6 (Sequola), Xcode 15.3, LC 10.0.2, iOS 18.6.2
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 939
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Hi Klaus, is it possible to do this "catch" thing in pointer mode? If so, script in card or somewhere else?Klaus wrote: Mon Mar 13, 2023 1:03 pm The message(s):
newcard
newbutton
newfield
etc.
is/are sent to the newly created object, so you could "catch" that in your card script.
Thanks
macOS 15.6 (Sequola), Xcode 15.3, LC 10.0.2, iOS 18.6.2
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 939
- Joined: Thu Nov 13, 2008 6:48 am
Re: Message sent when object placed onto card
Hi Craig, I am presuming (based on some experiments) that these messages are not sent up the message path to the card in pointer mode? Which leads to a broader question, are any messages sent in pointer mode? (and to clarify, I am referring to drag/drop actions from the tools palette).dunbarx wrote: Mon Mar 13, 2023 3:49 pm There are at least a dozen "new..." messages sent whenever anything, er, new is created. They are invaluable. Look up "new" in the dictionary for a complete list.
Craig
Cheers,
Mark
macOS 15.6 (Sequola), Xcode 15.3, LC 10.0.2, iOS 18.6.2
Re: Message sent when object placed onto card
Hi Mark,
just made a test:
Created a new stack with an opaque graphic, because a "naked" card does not accept any DRAG_XXX message.
Added this script:
Then I used the message box in POINTER mode :
and got the seconds.
Then I dragged a file onto the card, still in POINTER mode and saw the PLUS cursor.
I think the LC tools palette also works with DRAG_XXX messages.
Hope that will answer your questions.
Best
Klaus
P.S.
Not sure, but maybe the IDE will catch the "new_xxxx" messages if you drag'n'drop
an object from the tools palette?
just made a test:
Created a new stack with an opaque graphic, because a "naked" card does not accept any DRAG_XXX message.
Added this script:
Code: Select all
on dragEnter
set the dragaction to "copy"
end dragEnter
on newbutton
put the seconds
end newbuttonCode: Select all
create button in cd 1 of stack "test"Then I dragged a file onto the card, still in POINTER mode and saw the PLUS cursor.
I think the LC tools palette also works with DRAG_XXX messages.
Hope that will answer your questions.
Best
Klaus
P.S.
Not sure, but maybe the IDE will catch the "new_xxxx" messages if you drag'n'drop
an object from the tools palette?
-
richmond62
- Livecode Opensource Backer

- Posts: 10415
- Joined: Fri Feb 19, 2010 10:17 am
Re: Message sent when object placed onto card
I did, AND there seems to be no newControl or newObject,Look up "new" in the dictionary for a complete list.
or, for the sake of argument just new by itself.
THIS, in the cardScript does nothing:
Code: Select all
on newButton
put the name of the last control && the id of the last control
end newButtonRe: Message sent when object placed onto card
Your script in my card shows this correctly in the msg:
button id 1003 1003
macOS 12,6.3 LC 9.6.9 rc2
button id 1003 1003
macOS 12,6.3 LC 9.6.9 rc2
Re: Message sent when object placed onto card
Works for me as well. How could it not?
Craig
Craig
Re: Message sent when object placed onto card
Yes, Richmond, how could it not? 
-
richmond62
- Livecode Opensource Backer

- Posts: 10415
- Joined: Fri Feb 19, 2010 10:17 am
Re: Message sent when object placed onto card
Dunno: LC 8.1.10, MacOS 10.7.5
Re: Message sent when object placed onto card
Richmond.
Posting a tiny stack example is right up your alley.
Craig
Posting a tiny stack example is right up your alley.
Craig