Alaska Software Inc. - XbpDialog():setModalState(.t.)
Username: Password:
AuthorTopic: XbpDialog():setModalState(.t.)
Carlos A Beling XbpDialog():setModalState(.t.)
on Fri, 11 Sep 2020 19:20:03 -0300
Hi.
Good night.

Please, can anyone to make the function  IsModal() coded in Xbpget.prg 
work app modal as ConfirmBox() can to do, even that the popup menu of 
XbpMle() to be shown?
Please see the programs attached.
I looked in the NGs for solution like this and I found nothing.

Fraternally
Beling


Test.zip
Andreas Gehrs-Pahl
Re: XbpDialog():setModalState(.t.)
on Sun, 13 Sep 2020 13:23:43 -0400
Carlos,

I don't quite understand what your question / request is. But to make the 
dialog with the MLE (that appears when the first XbpGet loses focus) a modal 
dialog, you need to set that dialog's modal state to AppModal, which you 
don't do.

So, to fix that particular issue, add the following lines to your code:

1) after "oDlg := XbpDialog():New(...)"

oDlg:SetModalState(XBP_DISP_APPMODAL)

2) and after "enddo"

oDlg:SetModalState(XBP_DISP_MODELESS)
oDlg:Destroy()

This will make the popup dialog with the MLE a modal window and will close 
it after you press ESC or click on the [X] on its title bar.

You also set focus to the dialog instead of the MLE, which makes no sense. 

3) so, change the line: "oHadFocus := SetAppFocus(oDlg)" to:

oHadFocus := SetAppFocus(oMle)

4) You should also remove the "oMle:CaptureMouse(.t.)", as it isn't needed 
at all, because the MLE is the only object on that modal dialog anyway.

To (only) display the "oPopup" Menu, you should replace (or modify) the 
MLE's popup menu, rather than display a second popup menu afterwards, using 
the right mouse button's Up event, which is quite confusing.

If that isn't what you asked, please try to explain your issue in more 
detail, possibly using Google Translate to refine your message -- by 
translating it back and forth -- until it makes sense in both languages.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Carlos A Beling Re: XbpDialog():setModalState(.t.)
on Tue, 15 Sep 2020 10:44:49 -0300
Hello Andreas.
Good day.
Many thanks again.
Sorry to bother you with my horrify english.
I did the changes that you advised to me and the only problem that 
remais is that when I click the right or left button on any XbpGet 
object the second XbpGet() gains the focus and the XbpMle() loses its 
one. Is it possible to fix this changing of focus for the XbpMle() does 
not loose its focus?
I attached the corrections that I did for you can to see what happens.

Fraternally
Beling

On 13/09/2020 14:23, Andreas Gehrs-Pahl wrote:
> Carlos,
> 
> I don't quite understand what your question / request is. But to make the
> dialog with the MLE (that appears when the first XbpGet loses focus) a modal
> dialog, you need to set that dialog's modal state to AppModal, which you
> don't do.
> 
> So, to fix that particular issue, add the following lines to your code:
> 
> 1) after "oDlg := XbpDialog():New(...)"
> 
> oDlg:SetModalState(XBP_DISP_APPMODAL)
> 
> 2) and after "enddo"
> 
> oDlg:SetModalState(XBP_DISP_MODELESS)
> oDlg:Destroy()
> 
> This will make the popup dialog with the MLE a modal window and will close
> it after you press ESC or click on the [X] on its title bar.
> 
> You also set focus to the dialog instead of the MLE, which makes no sense.
> 
> 3) so, change the line: "oHadFocus := SetAppFocus(oDlg)" to:
> 
> oHadFocus := SetAppFocus(oMle)
> 
> 4) You should also remove the "oMle:CaptureMouse(.t.)", as it isn't needed
> at all, because the MLE is the only object on that modal dialog anyway.
> 
> To (only) display the "oPopup" Menu, you should replace (or modify) the
> MLE's popup menu, rather than display a second popup menu afterwards, using
> the right mouse button's Up event, which is quite confusing.
> 
> If that isn't what you asked, please try to explain your issue in more
> detail, possibly using Google Translate to refine your message -- by
> translating it back and forth -- until it makes sense in both languages.
> 
> Hope that helps,
> 
> Andreas
>


Test.zip
Andreas Gehrs-Pahl
Re: XbpDialog():setModalState(.t.)
on Wed, 16 Sep 2020 16:19:32 -0400
>Sorry to bother you with my horrify english.

It's no bother, but I can't help much when I don't understand what your 
actual problem is.

>I did the changes that you advised to me and the only problem that 
>remais is that when I click the right or left button on any XbpGet 
>object the second XbpGet() gains the focus and the XbpMle() loses its 
>one. Is it possible to fix this changing of focus for the XbpMle() does 
>not loose its focus?

The MLE -- in the popup dialog which is called from the post-validation 
codeblock of the first XbpGet object on the main dialog -- will never lose 
focus, unless you close the popup dialog (and destroy the MLE), as the popup 
dialog is modal. You can't leave it and return to the main dialog, unless 
you close it. So, the above makes no sense, as the MLE can never lose focus!

I still do not understand what you are trying to accomplish. The "IsModal()" 
function, which is called by the post-validation codeblock of the first 
XbpGet object on the main dialog always returns TRUE. That means, the only 
variable that decides if that XbpGet object can be left by going to a 
different object -- with the mouse or the keyboard -- is the empty() 
function that follows it in the post-validation codeblock.

Therefore, if there is any text in that XbpGet object, then you can go to a 
different entry field. If it is empty, you can't. It doesn't matter what you 
do in your "IsModal()" function, only the return value matters. And changing 
the focus with "SetAppFocus(oHadFocus)" in that routine has absolutely no 
effect on the main dialog, as the XbpGetController and the XbpGet object 
decide which entry field receives or retains focus, based on validations.

So, please explain what the purpose of the "IsModal()" function and the MLE 
actual is and what you are trying to accomplish.

Also, keep in mind that if your IsModal() function returns FALSE, you can't 
even close the main dialog and the program can only be ended with ALT+C.

Depending on what you actually want to accomplish, you probably need to 
modify (or replace) the XbpGetController and/or the XbpGet class(es) to make 
them behave the way you want.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Carlos A Beling Re: XbpDialog():setModalState(.t.)
on Wed, 16 Sep 2020 19:12:22 -0300
Hi Andreas.
Good night.
Many thanks again.
That's what I want: that none window reacts to mouse's event while the 
XbpMle() has focus.After reading carefuly your answer and studying the 
methods XbpDialog:show() and XbpDialog:showModal() I changed the 
test.prg and right now it is working as I wanted (if you want, please 
see the attached file).
Many thanks again.

Fraternally
Beling


On 16/09/2020 17:19, Andreas Gehrs-Pahl wrote:
>> Sorry to bother you with my horrify english.
> 
> It's no bother, but I can't help much when I don't understand what your
> actual problem is.
> 
>> I did the changes that you advised to me and the only problem that
>> remais is that when I click the right or left button on any XbpGet
>> object the second XbpGet() gains the focus and the XbpMle() loses its
>> one. Is it possible to fix this changing of focus for the XbpMle() does
>> not loose its focus?
> 
> The MLE -- in the popup dialog which is called from the post-validation
> codeblock of the first XbpGet object on the main dialog -- will never lose
> focus, unless you close the popup dialog (and destroy the MLE), as the popup
> dialog is modal. You can't leave it and return to the main dialog, unless
> you close it. So, the above makes no sense, as the MLE can never lose focus!
> 
> I still do not understand what you are trying to accomplish. The "IsModal()"
> function, which is called by the post-validation codeblock of the first
> XbpGet object on the main dialog always returns TRUE. That means, the only
> variable that decides if that XbpGet object can be left by going to a
> different object -- with the mouse or the keyboard -- is the empty()
> function that follows it in the post-validation codeblock.
> 
> Therefore, if there is any text in that XbpGet object, then you can go to a
> different entry field. If it is empty, you can't. It doesn't matter what you
> do in your "IsModal()" function, only the return value matters. And changing
> the focus with "SetAppFocus(oHadFocus)" in that routine has absolutely no
> effect on the main dialog, as the XbpGetController and the XbpGet object
> decide which entry field receives or retains focus, based on validations.
> 
> So, please explain what the purpose of the "IsModal()" function and the MLE
> actual is and what you are trying to accomplish.
> 
> Also, keep in mind that if your IsModal() function returns FALSE, you can't
> even close the main dialog and the program can only be ended with ALT+C.
> 
> Depending on what you actually want to accomplish, you probably need to
> modify (or replace) the XbpGetController and/or the XbpGet class(es) to make
> them behave the way you want.
> 
> Hope that helps,
> 
> Andreas
>


Test.zip
Andreas Gehrs-Pahl
Re: XbpDialog():setModalState(.t.)
on Thu, 17 Sep 2020 01:27:43 -0400
Carlos,

>That's what I want: that none window reacts to mouse's event while the 
>XbpMle() has focus.After reading carefuly your answer and studying the 
>methods XbpDialog:show() and XbpDialog:showModal() I changed the 
>test.prg and right now it is working as I wanted (if you want, please 
>see the attached file).

You totally over-complicated that. Instead, you only needed to move the 
"oDlg:SetModalState(XBP_DISP_APPMODAL)" line AFTER the "oDlg:Create()" in 
your previous program. Then that program works exactly the same as your 
new program.

I didn't notice this before, but in your original program, you had:
"oDlg := XbpDialog():New( ... ):Create()" and instead of just adding 
"oDlg:SetModalState(XBP_DISP_APPMODAL)" after that line (as I suggested 
in my response), you removed the ":Create()" and placed it after the 
"oDlg:SetModalState(XBP_DISP_APPMODAL)" line. But you can :SetModalState() 
only after you :Create() a dialog, so that line had no effect at all.

Also, your new program doesn't reset the ModalState of your dialog before 
destroying it, which might cause issues with the disabled dialogs. And your 
"SetAppFocus(oHadFocus)" line still has no purpose and should be removed.

So, your only actual error (which I missed, as I didn't compile and run 
your modified code) was to separate and move the "oDlg:Create()" after the 
"oDlg:SetModalState()".

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Carlos A Beling Re: XbpDialog():setModalState(.t.)
on Thu, 17 Sep 2020 12:39:30 -0300
Hello Andreas:
good day.
Every day learning much more.
The errors became from a testing program from wich I copied and pasted 
the creation of XppDialog(), where :setModalState() was before the 
:create() method and I did not give attention to this problem.
When I simplifyed my testing program as you advised and now it is 
working as fine as I wanted.

Fraternally
Beling


On 17/09/2020 02:27, Andreas Gehrs-Pahl wrote:
> Carlos,
> 
>> That's what I want: that none window reacts to mouse's event while the
>> XbpMle() has focus.After reading carefuly your answer and studying the
>> methods XbpDialog:show() and XbpDialog:showModal() I changed the
>> test.prg and right now it is working as I wanted (if you want, please
>> see the attached file).
> 
> You totally over-complicated that. Instead, you only needed to move the
> "oDlg:SetModalState(XBP_DISP_APPMODAL)" line AFTER the "oDlg:Create()" in
> your previous program. Then that program works exactly the same as your
> new program.
> 
> I didn't notice this before, but in your original program, you had:
> "oDlg := XbpDialog():New( ... ):Create()" and instead of just adding
> "oDlg:SetModalState(XBP_DISP_APPMODAL)" after that line (as I suggested
> in my response), you removed the ":Create()" and placed it after the
> "oDlg:SetModalState(XBP_DISP_APPMODAL)" line. But you can :SetModalState()
> only after you :Create() a dialog, so that line had no effect at all.
> 
> Also, your new program doesn't reset the ModalState of your dialog before
> destroying it, which might cause issues with the disabled dialogs. And your
> "SetAppFocus(oHadFocus)" line still has no purpose and should be removed.
> 
> So, your only actual error (which I missed, as I didn't compile and run
> your modified code) was to separate and move the "oDlg:Create()" after the
> "oDlg:SetModalState()".
> 
> Hope that helps,
> 
> Andreas
>