Page 3 of 4

Re: Message sent when object placed onto card

Posted: Fri Mar 17, 2023 5:30 pm
by jacque
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.

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 6:52 pm
by marksmithhfx
dunbarx wrote: Thu Mar 16, 2023 1:51 pm Is it possible you are trying to send that sort of message when you pull a control from the tools palette? Those messages are not sent when you do that.

Craig
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

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 8:46 pm
by marksmithhfx
jacque wrote: Fri Mar 17, 2023 5:30 pm 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.
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
I've taken to piggy-backing onto the drop handler (in the card) to insert this handler into the PG, but that is not an ideal place for it. Better would be to insert the script of the PG when the control is added to the card (I think).

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
Open to suggestions but short of having a message sent (in pointer mode) to indicate when a control is added I can't think of a better way.

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.

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 8:50 pm
by richmond62
That's a funny way of including images.

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 8:52 pm
by marksmithhfx
richmond62 wrote: Sun Mar 19, 2023 8:50 pm That's a funny way of including images.
Yeah, I couldn't remember the name of the img url website, so improvised 8)

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 9:21 pm
by dunbarx
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

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 9:35 pm
by marksmithhfx
dunbarx wrote: Sun Mar 19, 2023 9:21 pm 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
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?

Mark

Re: Message sent when object placed onto card

Posted: Sun Mar 19, 2023 9:38 pm
by dunbarx
Standalone can do anything the IDE can.

Craig

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 2:36 am
by Emily-Elizabeth
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
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.

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 4:13 am
by dunbarx
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

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 10:24 am
by marksmithhfx
Emily-Elizabeth wrote: Mon Mar 20, 2023 2:36 am 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.
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).

Best, and thanks again for the reminder.
Mark

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 11:06 am
by richmond62
Screen Shot 2023-03-20 at 12.04.57 pm.png
-
Screen Shot 2023-03-20 at 12.05.19 pm.png
-
Mark; can you please post your images inwith the body of a message as . . . .

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 12:43 pm
by marksmithhfx
richmond62 wrote: Mon Mar 20, 2023 11:06 am Mark; can you please post your images inwith the body of a message as . . . .
Hi Richmond,

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

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 1:16 pm
by Klaus
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.
image1.jpg
image2.jpg

Re: Message sent when object placed onto card

Posted: Mon Mar 20, 2023 2:59 pm
by marksmithhfx
Klaus wrote: Mon Mar 20, 2023 1:16 pm 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.
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 :shock: ).

Mark