Resizable Dialog With Multiple Buttons
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Resizable Dialog With Multiple Buttons
Hi, I was wondering how I could script a dialogue to automatically resize like Answer dialogue does, additionally I was wanting to know how to get the dialogue to create multiple buttons like the answer dialogue does.
I just took a look through the Answer dialogues scripts just now, but (For lack of a better description) its went straight over the top of my head, additionally I want my dialogues to look unique. It's so I can minimise the number of custom dialogue in my stack files as well as use a single universal design for my dialogues.
Many thanks in advance. Michael.
I just took a look through the Answer dialogues scripts just now, but (For lack of a better description) its went straight over the top of my head, additionally I want my dialogues to look unique. It's so I can minimise the number of custom dialogue in my stack files as well as use a single universal design for my dialogues.
Many thanks in advance. Michael.
Re: Resizable Dialog With Multiple Buttons
Hi.
The best method is to make your own. Make a small stack that has all the controls you need. Stacks can be used for these simple purposes; in other words they don't have to be a big deal, and then you have total control. Many people think that a stack is only something the main app is built from. Not necessarily.
As to resizing, is there going to be a field on your stack that needs to just fit some quantity of data? No problem. Write back if you need help.
Craig Newman
The best method is to make your own. Make a small stack that has all the controls you need. Stacks can be used for these simple purposes; in other words they don't have to be a big deal, and then you have total control. Many people think that a stack is only something the main app is built from. Not necessarily.
As to resizing, is there going to be a field on your stack that needs to just fit some quantity of data? No problem. Write back if you need help.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Resizable Dialog With Multiple Buttons
Hi Dunbarx
I have had a slightly closer look at the Answer Dialogue script and it shows a limit in the number of buttons at 7. So I think I could just setup the script of the stack to determine whether or not to show the right number of buttons (And thus have the buttons already available during design) but it is the active resizing of the dialogue which still eludes me.
Because I want to create my own custom Error, Information, Question and Warning dialogue which automatically resizes itself based on the size of the message involved so that the field doesn't need to show a scrollbar (Which looks really out of place in a label field). I tried this method before but often enough the stack would resize itself wrong and be bigger than it needed to be or the message would end up occupying to much vertical space.
If you look at the Answer Dialogue when it is given a message, it often resizes itself automatically both vertically and horizontally. But as I said the script just looks so confusing.
I have had a slightly closer look at the Answer Dialogue script and it shows a limit in the number of buttons at 7. So I think I could just setup the script of the stack to determine whether or not to show the right number of buttons (And thus have the buttons already available during design) but it is the active resizing of the dialogue which still eludes me.
Because I want to create my own custom Error, Information, Question and Warning dialogue which automatically resizes itself based on the size of the message involved so that the field doesn't need to show a scrollbar (Which looks really out of place in a label field). I tried this method before but often enough the stack would resize itself wrong and be bigger than it needed to be or the message would end up occupying to much vertical space.
If you look at the Answer Dialogue when it is given a message, it often resizes itself automatically both vertically and horizontally. But as I said the script just looks so confusing.
Re: Resizable Dialog With Multiple Buttons
Hi.
This is easy, (and I bet the geometry manager, which I have never used, might do it automatically).
For example, in your dialog, if you have a text field sitting above a number of buttons, you can get the "formattedHeight" of the field after you load it with text. You already know how much height you need to show the buttons. Add them together and you have the required height of the stack window. Simply set the window height to this value whenever you show the dialog.
Is this clear? It is very simple to implement.
Craig Newman
This is easy, (and I bet the geometry manager, which I have never used, might do it automatically).
For example, in your dialog, if you have a text field sitting above a number of buttons, you can get the "formattedHeight" of the field after you load it with text. You already know how much height you need to show the buttons. Add them together and you have the required height of the stack window. Simply set the window height to this value whenever you show the dialog.
Is this clear? It is very simple to implement.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Resizable Dialog With Multiple Buttons
I tried such a method the other week, but for some strange reason each time the stack opened it added more to the stacks height. I have got an idea which involves experimenting with the answer stack (I will back it up first of course). I'll post what happens here if you like?
Re: Resizable Dialog With Multiple Buttons
Do you mean the stack got higher and higher each time? Or that it just was higher than you wanted?
I assume there are no stack menus, if this is on a Mac.
I assume there are no stack menus, if this is on a Mac.
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Resizable Dialog With Multiple Buttons
There aren't any menus and yeah it just got higher and higher. I think it is down to a bug in the code I had, additionally I'm creating the stack on Windows first and then thinking about porting it to Mac once its perfected.
Re: Resizable Dialog With Multiple Buttons
mickpitkin92,
This might be a Revolution bug. Apparently, you open the stack hidden and set the size of the stack and the objects before showing the stack. The problem could be that the rect of this stack reports a different size until after the (pre)OpenStack handlers have run.
A solution might be to send a message in the preOpenStack handler:
I can't guarantee that it will work, but it is worth a try.
Best,
Mark
This might be a Revolution bug. Apparently, you open the stack hidden and set the size of the stack and the objects before showing the stack. The problem could be that the rect of this stack reports a different size until after the (pre)OpenStack handlers have run.
A solution might be to send a message in the preOpenStack handler:
Code: Select all
on preOpenStack
send "initialise" to me in 0 millisecs
end preOpenStack
on initialise
-- resize your stack here
end initialise
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- VIP Livecode Opensource Backer
- Posts: 246
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Resizable Dialog With Multiple Buttons
Hi Mark and Dunbarx
I have finished work on what I have been working, the resizable stack is called Custom Answer Dialog.rev and their is a a stack Interface To New Alert Dialog.rev which contains a button which uses a function in the stack to issue the new stack similar to the Answer command.
Feel free to look around the two stacks and let me know if there are any places where you believe additional functionality could be placed please. Thanks.
http://cid-59d8d0fb5766fc62.office.live ... Dialog.zip
I have finished work on what I have been working, the resizable stack is called Custom Answer Dialog.rev and their is a a stack Interface To New Alert Dialog.rev which contains a button which uses a function in the stack to issue the new stack similar to the Answer command.
Feel free to look around the two stacks and let me know if there are any places where you believe additional functionality could be placed please. Thanks.
http://cid-59d8d0fb5766fc62.office.live ... Dialog.zip