Page 1 of 4

Message sent when object placed onto card

Posted: Mon Mar 13, 2023 12:30 pm
by marksmithhfx
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

Re: Message sent when object placed onto card

Posted: Mon Mar 13, 2023 12:46 pm
by richmond62
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)

Re: Message sent when object placed onto card

Posted: Mon Mar 13, 2023 1:03 pm
by Klaus
The message(s):
newcard
newbutton
newfield
etc.

is/are sent to the newly created object, so you could "catch" that in your card script.

Re: Message sent when object placed onto card

Posted: Mon Mar 13, 2023 1:09 pm
by marksmithhfx
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!

Re: Message sent when object placed onto card

Posted: Mon Mar 13, 2023 3:49 pm
by dunbarx
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

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 10:42 am
by marksmithhfx
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.

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 11:04 am
by marksmithhfx
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

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 11:16 am
by marksmithhfx
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

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 12:33 pm
by Klaus
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?

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 1:08 pm
by richmond62
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

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 1:24 pm
by Klaus
Your script in my card shows this correctly in the msg:
button id 1003 1003

macOS 12,6.3 LC 9.6.9 rc2

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 2:33 pm
by dunbarx
Works for me as well. How could it not?

Craig

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 2:43 pm
by Klaus
Yes, Richmond, how could it not? :D

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 4:57 pm
by richmond62
Dunno: LC 8.1.10, MacOS 10.7.5

Re: Message sent when object placed onto card

Posted: Wed Mar 15, 2023 5:53 pm
by dunbarx
Richmond.

Posting a tiny stack example is right up your alley.

Craig