Designing your own modal dialogue box from scratch

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

Post Reply
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 4:57 pm

I saw the tutorial "how do I create a modal dialogue" but that does not look like what I ma after, some searching turns up nothing even on this forum, has the question been asked before? It must have been. I want to design a custom modal dialogue box, with different shape colour feel and look. Logic says surely this can be done, but all I can see is creating a substack and fiddling around there, but this is not the same thing as making your own modal box. Is it possible? If so, is there a tutorial?

Thankyou
chris

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Designing your own modal dialogue box from scratch

Post by FourthWorld » Fri Nov 15, 2013 5:27 pm

Stacks can be opened in different modes by using the command name that corresponds to that mode. For example, to open a stack as a palette you would use:

Code: Select all

palette "MyStack"
...and to open as a modal dialog:

Code: Select all

modal "MyStack"
Be sure to include a button that will close the stack before testing it, because, being modal, there will be no other way to close it other than quitting LiveCode.

You may also want to see the Dictionary entry for the dialogData global property for a convenient way to pass data between the dialog and the handler that opens it.

Custom window shapes are defined by the windowShape stack property, but I'm not sure if custom window shapes can be used with modal dialogs. You'll have to test that, but I would encourage you to think about doing so very carefully, as modal dialogs are very specialized, locking the user out of all other interactions with your program, and usually follow well-defined human interface guidelines so they can be readily acted on and dismissed so the user can get back to work. Straying from the HIG conventions users are accustomed to always carries at least some risk of inadequate guidance or even confusion, and given the highly specialized role of modal dialogs even more so.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 7:51 pm

Sounds like I have no idea now what on earth a modal dialogue box is. Typical. obviously got that wrong.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Designing your own modal dialogue box from scratch

Post by dunbarx » Fri Nov 15, 2013 8:24 pm

Chris.

Modals? Just another stack style. Richard made a great point. Make sure you have nothing you need to save, or better, shut down LC and start a new session. Make a new mainstack. In the msg box, type "modal this stack".

You can run, but you cannot hide. The msg box is useless.

The stack can have anything a normal stack can, but if you do not have a button on it that dismisses, it, or navigates to another stack, or changes it back to something less intransigent, you will have it forever. You have to quit LC to start over. Ornery little devils. Modals generally float around, usually over other stacks, and require user input to proceed.

Craig

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Designing your own modal dialogue box from scratch

Post by Simon » Fri Nov 15, 2013 8:53 pm

Hi Chris,
Sounds like I have no idea now what on earth a modal dialogue box is.
Sure you do, you use one all the time.
The Answer box is model.
Luckily it always comes up with an "OK" button to close it down -- That is the point of all the cautions above, gotta have a way to close the darn thing or you'll never be able to work with the main stack.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 9:10 pm

Closing down in a mac is easy guys, just hold command cntrol shift and click to bring up the contextual menu where you can then go to top level editing. At least that is the theory. But yes you are right - caution. Modal? This is where I got lost, I want to create a custom answer box with aesthetic appeal so that the user will want to keep bring it up again and again :lol: seriously, that was what I was asking, the tutorial gave no indication about this, so I asked. So I could create something in an illustrator programme and import it into LC and then place it on a substack and then follow the tutorial about the code?

chris

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Designing your own modal dialogue box from scratch

Post by dunbarx » Fri Nov 15, 2013 9:13 pm

Make a small stack just the way you want it, and pretend it is a custom answer box. Illustrator? Ptui.

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 9:16 pm

But the darn thing is square! You mean I can use the customwindowshape thingamajig-thingy-bob what-not?

(I know my terminology will annoy a few purists) :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Designing your own modal dialogue box from scratch

Post by Simon » Fri Nov 15, 2013 9:23 pm

Yup custom-shape-whatever

You should also look into setting the location of the stack when it opens. probably use the same loc as the main stack.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 9:44 pm

OK simon, thankyou very much.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Designing your own modal dialogue box from scratch

Post by Simon » Fri Nov 15, 2013 9:49 pm

I should not be so flippant
The property is windowShape

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Designing your own modal dialogue box from scratch

Post by FourthWorld » Fri Nov 15, 2013 10:16 pm

Here ya' go:

LiveCode Lessons: How to make a stack with a window shape
http://runrev.screenstepslive.com/s/les ... ndow-shape
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Designing your own modal dialogue box from scratch

Post by chris25 » Fri Nov 15, 2013 10:20 pm

Ah so kind Richard, but found this last week. I was just wanting to make sure that I could actually make any type of (modal)answer box that I wanted. Hope you did not spend too much time looking for this. Now I feel guilty :cry:

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Designing your own modal dialogue box from scratch

Post by FourthWorld » Fri Nov 15, 2013 10:42 pm

No problem. I just checked, and yes indeed the modal command preserves the stack's windowShape.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply