Message sent when object placed onto card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Message sent when object placed onto card

Post by marksmithhfx » Mon Mar 13, 2023 12:30 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9446
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Message sent when object placed onto card

Post by richmond62 » Mon Mar 13, 2023 12:46 pm

NO, no message is sent.

BUT, if you do this:

Code: Select all

put the id of the last control
you will get what you need. 8)

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message sent when object placed onto card

Post by Klaus » 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.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Message sent when object placed onto card

Post by marksmithhfx » Mon Mar 13, 2023 1:09 pm

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!
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9743
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Message sent when object placed onto card

Post by dunbarx » 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

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Message sent when object placed onto card

Post by marksmithhfx » Wed Mar 15, 2023 10:42 am

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
Thanks Craig.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Message sent when object placed onto card

Post by marksmithhfx » Wed Mar 15, 2023 11:04 am

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.
Hi Klaus, is it possible to do this "catch" thing in pointer mode? If so, script in card or somewhere else?

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

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: Message sent when object placed onto card

Post by marksmithhfx » Wed Mar 15, 2023 11:16 am

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
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).

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

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message sent when object placed onto card

Post by Klaus » Wed Mar 15, 2023 12:33 pm

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:

Code: Select all

on dragEnter
   set the dragaction to "copy"   
end dragEnter

on newbutton
   put the seconds
end newbutton
Then I used the message box in POINTER mode :

Code: Select all

create button in cd 1 of stack "test"
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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9446
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Message sent when object placed onto card

Post by richmond62 » Wed Mar 15, 2023 1:08 pm

Look up "new" in the dictionary for a complete list.
I did, AND there seems to be no newControl or newObject,

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 newButton

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message sent when object placed onto card

Post by Klaus » Wed Mar 15, 2023 1:24 pm

Your script in my card shows this correctly in the msg:
button id 1003 1003

macOS 12,6.3 LC 9.6.9 rc2

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9743
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Message sent when object placed onto card

Post by dunbarx » Wed Mar 15, 2023 2:33 pm

Works for me as well. How could it not?

Craig

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message sent when object placed onto card

Post by Klaus » Wed Mar 15, 2023 2:43 pm

Yes, Richmond, how could it not? :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9446
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Message sent when object placed onto card

Post by richmond62 » Wed Mar 15, 2023 4:57 pm

Dunno: LC 8.1.10, MacOS 10.7.5

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9743
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Message sent when object placed onto card

Post by dunbarx » Wed Mar 15, 2023 5:53 pm

Richmond.

Posting a tiny stack example is right up your alley.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”