Hi David,

I believe the issue involves whether this is a "modal" or "modeless" dialog.
I don't think I ever covered this in one of my classes (sorry about that
chief!).

I believe the default is "modal", which means your app stops all processing
when it hits the use of the Dialog() function, and picks back up when the
dialog is closed.  This isn't quite true, but the sub/function which uses
the Dialog() command does indeed stop processing at this line until the
dialog is closed for modal dialogs.

More important to you, when using a modal dialog, no value is returned by
the Dialog() function to go into your variable "MyDialog" because processing
has stopped; so it's always set to "nothing", and when you test on it later,
even when the dialog is open, this is what it will contain.


To make this work the way you want, I think you just need to go into the XML
properties for the dialog and set "modal" to "no" (making it a modeless
dialog), and remove the line at the end of the sub which sets MyDialog back
to nothing (actually move it into your dialog handler, when the dialog is
closing, so the global variable doesn't get set back to nothing until the
dialog is closed).



Below is the documentation for the modal property, but I believe it may be
incorrect when it says that "no" is the default value.

Chip

----


modal
 Specifies whether the dialog must be closed before interacting with the
calling application (i.e. a modal dialog) or whether the application can
receive user input even when the dialog is open (i.e. a modeless dialog).
Available options: Yes, No (default).


-----Original Message-----
From: Scripting
[mailto:scripting-bounces+lists3717=comcast....@lists.window-eyes.com] On
Behalf Of David via Scripting
Sent: Friday, October 07, 2016 9:12 PM
To: GWScripting
Subject: Single Instance Dialog Issue

Got a challenge here. I want to make sure only ONE instance of my dialog 
will be open, at any given time. The user will open the dialog with the 
Hotkey Win-c. But even if he tabs away from the dialog, and then once 
again hit Win-C, he should land in the already open dialog; not in a 
brand new window. Just like, when you hit the Ctrl-Backslash, you always 
land in one and same instance of the Window-Eyes Controlpanel.

Below you will find the cut-out of my code, that has to do with the 
opening of the dialog. In my Opening sub, I do the  lines:
     MyDialog.window.Activate
     MyDialog.window.Focus
But even this does not seem to fix my issue.

I am all learning ears, to any feedback you may have, or any good 
practice that you may want to share on this part.

Thanks to all,


---Snip-it:
Sub HK1(myKeyId)
     'This routine is called when the hotkey Alt-Windows-C is pressed.
     If Keyboard.KeyDescriberActive Then
         Speak myStrings(myKeyId & "_Description")
     Else
         'Main routine functionality goes here
         Queue "OpenMyAppWin"
     End IfKeyboard.KeyDescriberActive.
End Sub 'HK1.

Sub OpenMyAppWin()
     Dim MyDialog: Set MyDialog = Nothing
' Bring up the dialog:
     If MyDialog Is Nothing Then
         Set MyDialog = Dialog( myXMLFile, "MyAppMainDialog", 
"EHMainDialog")
     Else
         MyDialog.window.Activate
         MyDialog.window.Focus
     End If 'MyDialog Is Nothing.
' Room Cleaning:
     Set MyDialog = Nothing
End Sub 'OpenMyAppWin.

Function EHMainDialog( dObj, dEvent, dId, dControl)
Blah-blah-blah...
End Function 'EHMainDialog.
---End Of Snip.


-- 
David

_______________________________________________
Any views or opinions presented in this email are solely those of the author
and do not necessarily represent those of Ai Squared.

For membership options, visit
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/lists3717
%40comcast.net.
For subscription options, visit
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

_______________________________________________
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of Ai Squared.

For membership options, visit 
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/archive%40mail-archive.com.
For subscription options, visit 
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at 
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

Reply via email to