Question about Default option in dialog designer

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Question about Default option in dialog designer

Post by Rain » Fri May 12, 2006 1:19 pm

Default
ButtonObjectName
Sets the specified button object as the default button so that when Enter is pressed that button is invoked.
I understand what the option is suppose to do but what I can't figure out is how to use it :oops:
Can someone show me an example dialog?

Thanks in advanced.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 12, 2006 1:28 pm

It just means that when Enter is pressed while on another object (not a button obviously, because Enter clicks the focused button) that button is invoked. E.g. if you have an edit box and a default button, while the cursor is in the edit box if you hit Enter he default button is invoked.

Try this hashup:

Dialog>Dialog1
Caption=Dialog1
Width=434
Height=233
Top=202
Left=276
Button=msButton1,64,32,75,25,10
Button=msButton2,272,40,75,25,20
Button=msButton3,168,104,75,25,30
Edit=msEdit1,160,16,121,msEdit1
Edit=msEdit2,64,144,121,msEdit2
Default=msButton2
EndDialog>Dialog1

Show>Dialog1,r
MessageModal>r

Note that there are two edits and three buttons. The default is msButton2 which has modal value of 20. So run this and put the cursor in one of the edit boxes. Then press Enter. You will note that the dialog closes with modal value 20 proving that the default button was pressed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri May 12, 2006 3:42 pm

Thank you for your reply and example.
I get 10 as the result when I use your script and press the enter key right after starting it.
Is anyone else getting the same result (10) with 8.0.3 pro or is it just me?
Another questions, can this be used with none modal dialogs?

Thank you for your great support Marcus.

User avatar
JRL
Automation Wizard
Posts: 3502
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri May 12, 2006 4:04 pm

Rain,
Yes it works with non modal dialogs as well.

You are getting 10 as a result because the "msbutton1" object is the first thing in the dialog list so it is the focused object. Of course if you press enter it will be the object executed. If you first select an edit box then press enter you shoud get 20 as your result. Or you could rearrange the dialog objects so that the edit boxes are first in the list.



Dialog>Dialog1
Caption=Dialog1
Width=434
Height=233
Top=202
Left=276
Edit=msEdit1,160,16,121,msEdit1
Edit=msEdit2,64,144,121,msEdit2
Button=msButton1,64,32,75,25,10
Button=msButton2,272,40,75,25,20
Button=msButton3,168,104,75,25,30
Default=msButton2
EndDialog>Dialog1

Show>Dialog1,r
MessageModal>r


hope this helps,
Dick

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 12, 2006 4:42 pm

Rain wrote:Thank you for your reply and example.
I get 10 as the result when I use your script and press the enter key right after starting it.
Is anyone else getting the same result (10) with 8.0.3 pro or is it just me?
Another questions, can this be used with none modal dialogs?

Thank you for your great support Marcus.
You need to read my post again. I said:

"It just means that when Enter is pressed while on another object (not a button obviously, because Enter clicks the focused button) that button is invoked. E.g. if you have an edit box and a default button, while the cursor is in the edit box if you hit Enter he default button is invoked."

When you first start the dialog msButton1 is the first object on it so it has the focus, so pressing Enter invokes that button. If you put the focus in one of the text fields and then hit Enter, msButton2 will be invoked because it is the default button.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat May 13, 2006 8:14 am

Thanks Dick and Marcus.
:oops:
I apologize I had little to no sleep yesterday and misread your reply. After some rest I took a closer look at your post and example dialog and it finally made sense. I was under the impression that no matter what object is in focus the default button will be pressed when hitting the enter key. Sorry to have wasted your time Dick and Marcus. I want you two to know I really appreciate you guys for taking the time and explaining it to me.

~Rain

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts