Dialog> User Interface

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Dialog> User Interface

Post by armsys » Tue Apr 29, 2008 10:25 am

For the Dialog>..Show> construct,
1. for multiple tabpages, can the focus be programmatically set to the first item inside the page? Now, the focus is set to the page tab by default.
2. When the focus is set to an item in a Listbox, pressing ENTER won't exit the listbox.
3. OnEvent>KEY_DOWN,VK27,0,DoMeFavor won't work. Can the Dialog box be terminated by pressing ESC? How?
Thanks a lot for your help.

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

Post by JRL » Wed Apr 30, 2008 1:35 pm

1. for multiple tabpages, can the focus be programmatically set to the first item inside the page? Now, the focus is set to the page tab by default.
In the sample below, the Press Tab line immediately following Show>Dialog1 will move the focus to the first item in the tab page.
2. When the focus is set to an item in a Listbox, pressing ENTER won't exit the listbox.
Use the dialog "default" object. In the sample below if the focus is on a list box item and Enter is pressed, either the Result 4 or Result 6 button will be invoked, depending on which tab is current. If you just want to move to the next object, use the Tab key or your mouse.
3. OnEvent>KEY_DOWN,VK27,0,DoMeFavor won't work. Can the Dialog box be terminated by pressing ESC? How?
The sample's first line, OnEvent --> ESC (VK27) runs the Quit subroutine that goes to the EOF (EndOFFile) label. You could also use the new Exit> function in the Quit subroutine.

Hope this is helpful,
Dick

Code: Select all

OnEvent>Key_Down,VK27,0,Quit

Dialog>Dialog1
   Caption=Dialog Object Font Test
   Width=327
   Height=250
   Top=CENTER
   Left=CENTER
   TabBook=msTabBook1,16,16,289,193,0
      TabPage=Page1
         Label=This is page one,8,8
         Edit=msEdit1,16,88,121,msEdit1
		 ListBox=msListBox1,144,8,121,97,item 1 1%CRLF%item 1 2%CRLF%item 1 3
         Button=Result 3,16,128,75,25,3
         Button=Result 4,196,130,75,25,4
      TabPage=Page2
         Label=This is page two,8,8
         Edit=msEdit2,16,88,121,msEdit2
		 ListBox=msListBox2,152,8,121,97,item 2 1%CRLF%item 2 2%CRLF%item 2 3
         Button=Result 5,16,128,75,25,5
         Button=Result 6,196,130,75,25,6
   EndTabBook
		 Default=Result 4
		 Default=Result 6
EndDialog>Dialog1


Show>dialog1
Press tab

Label>Loop
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>res1=3,Process
If>res1=4,Process
If>res1=5,Process
If>res1=6,Process
Wait>0.01
Goto>Loop

Label>EOF

SRT>Process
  MDL>result=%res1%
  ResetDialogAction>dialog1
END>Process

SRT>Quit
  Goto>EOF
END>Quit

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

Post by Marcus Tettmar » Wed Apr 30, 2008 2:30 pm

Can the default focus issue not be fixed by changing the tab order in the dialog designer? Click the "Tab Order" 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
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Apr 30, 2008 3:53 pm

Can the default focus issue not be fixed by changing the tab order in the dialog designer?
I've never used Tab Order before and it doesn't seem to be doing anything now when I try it. I would assume that it automagically changes the position/order of the tabpage definitions within the dialog block. The issue is that the Tab itself is the focused item when you use tabs. Placing the Press Tab line after show>dialog for some reason sets focus to the first object in the tab page when a "tab" is selected.

To illustrate, run the sample above with the Press Tab line remarked. Pick the Page2 tab with the mouse and then press the backspace key. Nothing happens. Do the preceeding again with the Press Tab line un-remarked. When you press Backspace the msEdit2 test is backspaced over. MsEdit2 is the first object in the Page2 tab.

hope this makes sense.

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

Post by Marcus Tettmar » Wed Apr 30, 2008 4:22 pm

Tab Order is referring to "Tab Key" order - in other words, the order in which objects are focused - the order in which focus will change as you press the tab key to cycle through the objects. Nothing to do with the order of tab pages in a page control.

I just wondered if the issue of which object originally had the focus could be fixed by setting the tab order.

If you want to focus a specific object, use the Win32 SetFocus command and pass it the object handle:

LibFunc>user32,SetFocus,r,DIALOG1.MSEDIT2.HANDLE
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu May 01, 2008 1:50 am

Hi Dick,
Thanks for your help. However, both OnEvent and Press Tab failed on my PC. That's, pressing ESC won't quit the dialog window. The Press TAB statement won't set focus to the first item in the Listbox, the only object in the tab page. Sorry.

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

Post by JRL » Thu May 01, 2008 4:41 am

Since the sample I posted has more than one object in the tab page I assume you are having trouble with a script other than the sample.

Have you tried the sample as-is?

Can you share the script that is causing you problems?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Fri May 02, 2008 12:41 pm

Dick,

3 results are found so far:
1. Yours is of modeless dialog; mine is of modal dialog.
2. Yes, your script runs successfully satisfying all requirements--pressing Esc to exit and presing TAB to set focus to the first item instead of the page tab.
3. No, my script still doesn't work.

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

Post by JRL » Fri May 02, 2008 12:52 pm

Your script is modal therefore the script stops. All of the features such as Onevent require that the script not be stopped. There are ways to get around this but the simplest is to write the script so the dialog is modeless.

Sebastian589
Newbie
Posts: 1
Joined: Sun Nov 05, 2023 3:46 am

Re: Dialog> User Interface

Post by Sebastian589 » Fri Dec 15, 2023 6:52 am

Hello Guys,
I appreciate your assistance, but I encountered issues with both the OnEvent and Press Tab functions on my PC. Pressing ESC doesn't close the dialog window as expected. Additionally, the Press TAB statement doesn't successfully set focus to the first item in the Listbox, which is the sole object on the tab page. I apologize for any confusion and appreciate your continued support.

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