Palette stack of Custom Controls

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Palette stack of Custom Controls

Post by Simon Knight » Thu Jun 18, 2020 9:36 am

Hi,

The recent Livecode Lockdown video played a lecture given by UI expert Scott Rossi. His talk was about behaviours but in it he showed a set of custom controls for iOS that he use to maintain. These custom controls were displayed in a floating stack and the controls could be dragged into an open project stack for use.

I would like to create my own version of this toolbox palette and wonder if there is a common approach ?

I'm thinking of placing my actual custom controls on sub stacks which are hidden from view. The toolbox will just contain a number of images of the controls or perhaps icons that convey what the control does. Then the user (me) drags the image/icon from the toolbox onto a second stack and this causes the hidden control to be copied.

Is the above a sensible plan ?
best wishes
Skids

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

Re: Palette stack of Custom Controls

Post by richmond62 » Thu Jun 18, 2020 11:52 am

Simon Knight wrote:
Thu Jun 18, 2020 9:36 am
Is the above a sensible plan ?
Well, if you're looking for a subjective opinion that is certainly one way to obtain one.
a set of custom controls for iOS
The first question would be; "What for?"

I would only be looking to make a palette with custom controls for a programming IDE . . .

So, is that what you are speiran after with this on iOS?

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Palette stack of Custom Controls

Post by Simon Knight » Thu Jun 18, 2020 12:05 pm

Ah, I have confused - sorry.

Over the years I have created some of my own custom controls and I am thinking that it would be useful if I put them all together in one place to make them simpler to find. So this will just be for use by me in the IDE and it has nothing specific to do with Mobile, its just what Mr. Rossi demonstrated.

I appreciate that I could just use copy and paste my controls but in the talk Mr. Rossi had a working toolbox that allowed objects to be dragged to a second stack and dropped. So I thought "how is that done" which led to my question?
best wishes
Skids

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

Re: Palette stack of Custom Controls

Post by Klaus » Thu Jun 18, 2020 12:12 pm

Simon Knight wrote:
Thu Jun 18, 2020 12:05 pm
Ah, I have confused - sorry.
Only one guy in Bulgaria! 8)

Since iOS only supports ONE window/stack at a time it was more than clear that you mean a palette for development.
So, yes, this is a good plan! :D

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

Re: Palette stack of Custom Controls

Post by richmond62 » Thu Jun 18, 2020 12:51 pm

Klaus wrote:
Thu Jun 18, 2020 12:12 pm
Simon Knight wrote:
Thu Jun 18, 2020 12:05 pm
Ah, I have confused - sorry.
Only one guy in Bulgaria! 8)

Since iOS only supports ONE window/stack at a time it was more than clear that you mean a palette for development.
Lest you forget, Klaus, there are people who read this forum who know EVEN LESS than I do.

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Palette stack of Custom Controls

Post by Simon Knight » Thu Jun 18, 2020 1:00 pm

Ooo Eck, could be a good time for a 2m distant walk :D

I shall have a play with drag and drop stuff and see how lost I get....
best wishes
Skids

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7240
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Palette stack of Custom Controls

Post by jacque » Thu Jun 18, 2020 6:34 pm

I've never tried it, but I believe the IDE creates a small temporary stack with an image of the control in it (or maybe the control itself.) The stack follows the movement of the cursor and when the mouse goes up it creates a copy of the control on the target stack and deletes the temporary stack.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Palette stack of Custom Controls

Post by richmond62 » Thu Jun 18, 2020 8:57 pm

Popping across to the Metacard tools stack I extracted the substack "Tools" from it
and found this:

Code: Select all

on openStack
  insert script of button "MenuButton" of stack "MetaCard Menu Bar" into front
  insert script of button "newobj" of stack "MetaCard Menu Bar" into back
  newTool
end openStack
What particularly interests me is the line 'newTool' as I cannot locate a script 'newTool' anywhere.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Palette stack of Custom Controls

Post by bogs » Thu Jun 18, 2020 9:22 pm

Jacque, you are correct in Rev/Lc vers past 2.2 (I believe that started around 2.7/8, which is where the 'modern' tool palette starts). Prior to that, in vers. 1.1 to 2.(2? 3?) you clicked on the object you wanted to use, and it is much like Richmond says goes on in Mc. The main differences between Mc's way and Rev 1.1 - 2.2.x is that Mc had you draw the control, Rev actually used a template setup where the control was a default size when you 'placed' it.
Image

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Palette stack of Custom Controls

Post by Simon Knight » Thu Jun 18, 2020 10:11 pm

I have a working stack based on an old demonstration stack that I found. It needs a tidy up before I dare post it here and I'm just off for some shut eye.
So it will have to be tomorrow.
best wishes
Skids

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Palette stack of Custom Controls

Post by bogs » Fri Jun 19, 2020 12:46 pm

Although this references a 'mobile IDE' design, I thought it might be of some use in this thread, as many of the ideas presented should work out well in your case as well. Neil Roger really did an excellent job of detailing some of the thoughts and code that goes into such things.
Image

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Palette stack of Custom Controls

Post by Simon Knight » Fri Jun 19, 2020 12:51 pm

Hi All,

Here is a working stack that could be used to store any custom controls you have created. It is based on and uses the same technique that Peter Haworth employed in a demo he created some years ago.

I have updated and added to the code base. The palette is quite large owing to the long text instructions so for general use this should be deleted and the stack reduced in size.

The tricky part is moving behavior buttons to the target stack and re-assigning then to the newly copied custom control. (Note that this also an issue with images used by custom controls and the control should locate its own images when it starts)

So any volunteer beta testers?
DragExampleUpdatedv1.livecode.zip
Unzip for an example palette stack
(17.06 KiB) Downloaded 257 times
best wishes
Skids

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Palette stack of Custom Controls

Post by bn » Fri Jun 19, 2020 2:02 pm

Hi Simon,

that is a very neat example stack. Thank you.

For behavior buttons that are embedded in a grouped control I use the "newGroup" message that is sent to a group when it is created.

from the dictionary
Sent to a new group right after it's created.

Pseudocode for the group script (should work)

Code: Select all

on newGroup
   set the behavior of me to the long  id of button "myBehaviorButton" of me -- don't forget "of me" in case you have another button "myBehavior"
end newGroup
You could additionally trap the "openControl" or "preOpenControl" message that is sent to grouped controls to set the behavior. This is in case the stack is renamed. That way the behvavior should not break.

Kind regards
Bernd

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Palette stack of Custom Controls

Post by Simon Knight » Fri Jun 19, 2020 3:59 pm

Hi Bernd,

Great to hear from you and thanks for your comments and suggestions. I shall investigate the handlers you mention, the newgroup handler is especially interesting.

My aim was to experiment with drag and drop having seen a talk by Scott Rossi and to produce something that is both useful and that I might understand in a years time.

I'm of two minds where code should be placed in grouped controls and have tried various options with half finished attempts. Its a pity that Livecode does not provide a slightly more robust custom control construct but I suppose they would remind me that there is always Livecode Builder.

I think I am tending towards using an embedded behavior button. This will mean that all the code resides inside the group yet it remains simple to reassign multiple copies of a group control towards a single behavior button if desired. Adopting this approach will mean that I can use the newgroup handler as you describe and there should be less chance of the group becoming separated from its behavior button

Do you think others might find the stack of use if I posted it somewhere else on the web?
best wishes

Simon
best wishes
Skids

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Palette stack of Custom Controls

Post by bn » Fri Jun 19, 2020 5:28 pm

Simon Knight wrote:
Fri Jun 19, 2020 3:59 pm
Do you think others might find the stack of use if I posted it somewhere else on the web?
best wishes
I find it a very useful stack and think you could upload it to Livecodeshare for all to see. You have to register for that I think.

Kind regards
Bernd

Post Reply

Return to “Talking LiveCode”