Alaska Software Inc. - tdDEget
Username: Password:
AuthorTopic: tdDEget
Paul ChongtdDEget
on Mon, 23 Jul 2018 18:29:11 +0800
Hi all,

I have found a weird behaviour in the valid codeblock of tdDEget.

bValid := {|o,n| tdQMsg("How to exit block"),.T.}
oGet :=
tdDEget(nRow,nCol+5,fieldblock("IC_NO"),oDlg,aTset:aTabSet[1,2],12,,bValid)
oGet:setData()

During edit mode, this bValid suppose to get Eval to true & continue to
next get (Eval return last expression in the program code of <bValid>). But
instead after tdQmsg(), the focus return to the same get.

If i remove the tdQmsg(), it work. Other popup msg like tdYesNo, tdMsg &
etc will have same problem also.

Not sure if other TD gets have the same behaviour. Anyone knows about the
problem?

TIA

Paul
Jonathan LeemingRe: tdDEget
on Mon, 23 Jul 2018 07:28:46 -0600
On 7/23/2018 4:29 AM, Paul Chong wrote:
> Hi all,
> 
> I have found a weird behaviour in the valid codeblock of tdDEget.
> 
> bValid := {|o,n| tdQMsg("How to exit block"),.T.}
> oGet :=
> tdDEget(nRow,nCol+5,fieldblock("IC_NO"),oDlg,aTset:aTabSet[1,2],12,,bValid)
> oGet:setData()
> 
> During edit mode, this bValid suppose to get Eval to true & continue to
> next get (Eval return last expression in the program code of <bValid>). But
> instead after tdQmsg(), the focus return to the same get.
> 
> If i remove the tdQmsg(), it work. Other popup msg like tdYesNo, tdMsg &
> etc will have same problem also.
> 
> Not sure if other TD gets have the same behaviour. Anyone knows about the
> problem?
> 
> TIA
> 
> Paul
> 
Hi Paul,

As you noticed this happens with pretty much all popups called from 
within the validation routine.  I believe it is a result of a modal 
window conflicting with the SetInputFocus codeblock.

The solution would be to add o:oParentDlg:oActvGet := NIL to the 
validation routine after the popup just before the return.

Your bValid would then be:

bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet := 
NIL, .T.}

This should set the focus to the next get object as you expect.

Regards... Jonathan

jonathan.leeming@the-family-centre.com
Edmonton, Alberta, Canada
Paul ChongRe: tdDEget
on Tue, 24 Jul 2018 13:32:18 +0800
Hi Jonathan,

Your suggestion works. I have tested with the keyboard event and everything
is ok. Thanks. Surely its the modal focus problem.

However, mouse click react a bit weird. If i click on another get, the new
get will receive focus but at the same time it is in highlight mode. As if
the mouse LBClick is being activated.

For example, refer to screen shot, while focus is on IC NO, if i click on
Other between the '6' & '8' digit, Other get focus but when i move mouse
pointer to the right, it highlight part of the buffer.

To release that highlight mode just click on the buffer again. Any idea how
to overcome this?

TIA

Paul

On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
> 
> As you noticed this happens with pretty much all popups called from 
> within the validation routine.  I believe it is a result of a modal 
> window conflicting with the SetInputFocus codeblock.
> 
> The solution would be to add o:oParentDlg:oActvGet := NIL to the 
> validation routine after the popup just before the return.
> 
> Your bValid would then be:
> 
> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet := 
> NIL, .T.}
> 
> This should set the focus to the next get object as you expect.
> 
> Regards... Jonathan
Jonathan LeemingRe: tdDEget
on Tue, 24 Jul 2018 07:50:16 -0600
On 7/23/2018 11:32 PM, Paul Chong wrote:
> Hi Jonathan,
> 
> Your suggestion works. I have tested with the keyboard event and everything
> is ok. Thanks. Surely its the modal focus problem.
> 
> However, mouse click react a bit weird. If i click on another get, the new
> get will receive focus but at the same time it is in highlight mode. As if
> the mouse LBClick is being activated.
> 
> For example, refer to screen shot, while focus is on IC NO, if i click on
> Other between the '6' & '8' digit, Other get focus but when i move mouse
> pointer to the right, it highlight part of the buffer.
> 
> To release that highlight mode just click on the buffer again. Any idea how
> to overcome this?
> 
> TIA
> 
> Paul
> 
> On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
>>
>> As you noticed this happens with pretty much all popups called from
>> within the validation routine.  I believe it is a result of a modal
>> window conflicting with the SetInputFocus codeblock.
>>
>> The solution would be to add o:oParentDlg:oActvGet := NIL to the
>> validation routine after the popup just before the return.
>>
>> Your bValid would then be:
>>
>> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet :=
>> NIL, .T.}
>>
>> This should set the focus to the next get object as you expect.
>>
>> Regards... Jonathan
Hi Paul,

I tried to replicate the highlight issue but it does not occur within my 
application unless I right click...and hold... and move the mouse.  I 
did notice on one of my entry fields where I have the cPicture set to 
"@K" that the entire field get highlighted when I click anywhere in the 
field with a second click un-highlighting the field.  I don't know if 
other cPicture values give different behaviors.

Is it possible to create a simple code snippet that replicates your issue?

What version of Topdown, Xbase & Windows are you using.  I'm using TD 
9.1, Xbase 2.00.972 and Windows 10 1607.

Regards... Jonathan



jonathan.leeming@the-family-centre.com
Edmonton, Alberta, Canada
Paul ChongRe: tdDEget
on Wed, 25 Jul 2018 05:16:10 +0800
Hi Jonathan,

I'm using TD 9.1, Xbase 1.90.355 and Windows 7 7601.

I will use demDataWin.prg as sample from TD91Demo source. I have added 1
line the same bValid to phone tdDEget. You may need to backup original and
add new demDataWin.prg as attached than recompile TD91Demo.

Start the TD91Demo and run DE Window and DE Get window. Edit a record than
click the Phone get. Click on Address get now (try middle of the text) than
you will see tdQmsg and notice the highlight issue.

I have noticed the DOB Get has a bWhen and also the same issue. Try jump
from any Get to DOB Get and after choosing yes from tdYesNo, the highlight
issue is there.

However, the numeric Get is normal. Always highlight in full as usual.

I suspect this is TD issue, but just dont know where to look for.

TIA 

Paul

On Tue, 24 Jul 2018 07:50:16 -0600, Jonathan Leeming wrote:

> On 7/23/2018 11:32 PM, Paul Chong wrote:
>> Hi Jonathan,
>> 
>> Your suggestion works. I have tested with the keyboard event and everything
>> is ok. Thanks. Surely its the modal focus problem.
>> 
>> However, mouse click react a bit weird. If i click on another get, the new
>> get will receive focus but at the same time it is in highlight mode. As if
>> the mouse LBClick is being activated.
>> 
>> For example, refer to screen shot, while focus is on IC NO, if i click on
>> Other between the '6' & '8' digit, Other get focus but when i move mouse
>> pointer to the right, it highlight part of the buffer.
>> 
>> To release that highlight mode just click on the buffer again. Any idea how
>> to overcome this?
>> 
>> TIA
>> 
>> Paul
>> 
>> On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
>>>
>>> As you noticed this happens with pretty much all popups called from
>>> within the validation routine.  I believe it is a result of a modal
>>> window conflicting with the SetInputFocus codeblock.
>>>
>>> The solution would be to add o:oParentDlg:oActvGet := NIL to the
>>> validation routine after the popup just before the return.
>>>
>>> Your bValid would then be:
>>>
>>> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet :=
>>> NIL, .T.}
>>>
>>> This should set the focus to the next get object as you expect.
>>>
>>> Regards... Jonathan
> Hi Paul,
> 
> I tried to replicate the highlight issue but it does not occur within my 
> application unless I right click...and hold... and move the mouse.  I 
> did notice on one of my entry fields where I have the cPicture set to 
> "@K" that the entire field get highlighted when I click anywhere in the 
> field with a second click un-highlighting the field.  I don't know if 
> other cPicture values give different behaviors.
> 
> Is it possible to create a simple code snippet that replicates your issue?
> 
> What version of Topdown, Xbase & Windows are you using.  I'm using TD 
> 9.1, Xbase 2.00.972 and Windows 10 1607.
> 
> Regards... Jonathan


demDataWin.prg
Paul ChongRe: tdDEget
on Wed, 25 Jul 2018 12:55:55 +0800
Hi Jonathan,

I think the problem is at tdcDEget.prg. Refer to line 1462 - 1466. When the
new get receive focus by LbDown & the oActGet was assigned nil, xpbSle will
be treated as 'allow selection of text with mouse', line 1465.

Maybe this is the cause & that is why using keyboard is fine.

Any work around?

TIA

Paul

On Tue, 24 Jul 2018 07:50:16 -0600, Jonathan Leeming wrote:

> On 7/23/2018 11:32 PM, Paul Chong wrote:
>> Hi Jonathan,
>> 
>> Your suggestion works. I have tested with the keyboard event and everything
>> is ok. Thanks. Surely its the modal focus problem.
>> 
>> However, mouse click react a bit weird. If i click on another get, the new
>> get will receive focus but at the same time it is in highlight mode. As if
>> the mouse LBClick is being activated.
>> 
>> For example, refer to screen shot, while focus is on IC NO, if i click on
>> Other between the '6' & '8' digit, Other get focus but when i move mouse
>> pointer to the right, it highlight part of the buffer.
>> 
>> To release that highlight mode just click on the buffer again. Any idea how
>> to overcome this?
>> 
>> TIA
>> 
>> Paul
>> 
>> On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
>>>
>>> As you noticed this happens with pretty much all popups called from
>>> within the validation routine.  I believe it is a result of a modal
>>> window conflicting with the SetInputFocus codeblock.
>>>
>>> The solution would be to add o:oParentDlg:oActvGet := NIL to the
>>> validation routine after the popup just before the return.
>>>
>>> Your bValid would then be:
>>>
>>> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet :=
>>> NIL, .T.}
>>>
>>> This should set the focus to the next get object as you expect.
>>>
>>> Regards... Jonathan
> Hi Paul,
> 
> I tried to replicate the highlight issue but it does not occur within my 
> application unless I right click...and hold... and move the mouse.  I 
> did notice on one of my entry fields where I have the cPicture set to 
> "@K" that the entire field get highlighted when I click anywhere in the 
> field with a second click un-highlighting the field.  I don't know if 
> other cPicture values give different behaviors.
> 
> Is it possible to create a simple code snippet that replicates your issue?
> 
> What version of Topdown, Xbase & Windows are you using.  I'm using TD 
> 9.1, Xbase 2.00.972 and Windows 10 1607.
> 
> Regards... Jonathan
Jonathan LeemingRe: tdDEget
on Wed, 25 Jul 2018 08:28:49 -0600
On 7/24/2018 10:55 PM, Paul Chong wrote:
> Hi Jonathan,
> 
> I think the problem is at tdcDEget.prg. Refer to line 1462 - 1466. When the
> new get receive focus by LbDown & the oActGet was assigned nil, xpbSle will
> be treated as 'allow selection of text with mouse', line 1465.
> 
> Maybe this is the cause & that is why using keyboard is fine.
> 
> Any work around?
> 
> TIA
> 
> Paul
> 
> On Tue, 24 Jul 2018 07:50:16 -0600, Jonathan Leeming wrote:
> 
>> On 7/23/2018 11:32 PM, Paul Chong wrote:
>>> Hi Jonathan,
>>>
>>> Your suggestion works. I have tested with the keyboard event and everything
>>> is ok. Thanks. Surely its the modal focus problem.
>>>
>>> However, mouse click react a bit weird. If i click on another get, the new
>>> get will receive focus but at the same time it is in highlight mode. As if
>>> the mouse LBClick is being activated.
>>>
>>> For example, refer to screen shot, while focus is on IC NO, if i click on
>>> Other between the '6' & '8' digit, Other get focus but when i move mouse
>>> pointer to the right, it highlight part of the buffer.
>>>
>>> To release that highlight mode just click on the buffer again. Any idea how
>>> to overcome this?
>>>
>>> TIA
>>>
>>> Paul
>>>
>>> On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
>>>>
>>>> As you noticed this happens with pretty much all popups called from
>>>> within the validation routine.  I believe it is a result of a modal
>>>> window conflicting with the SetInputFocus codeblock.
>>>>
>>>> The solution would be to add o:oParentDlg:oActvGet := NIL to the
>>>> validation routine after the popup just before the return.
>>>>
>>>> Your bValid would then be:
>>>>
>>>> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet :=
>>>> NIL, .T.}
>>>>
>>>> This should set the focus to the next get object as you expect.
>>>>
>>>> Regards... Jonathan
>> Hi Paul,
>>
>> I tried to replicate the highlight issue but it does not occur within my
>> application unless I right click...and hold... and move the mouse.  I
>> did notice on one of my entry fields where I have the cPicture set to
>> "@K" that the entire field get highlighted when I click anywhere in the
>> field with a second click un-highlighting the field.  I don't know if
>> other cPicture values give different behaviors.
>>
>> Is it possible to create a simple code snippet that replicates your issue?
>>
>> What version of Topdown, Xbase & Windows are you using.  I'm using TD
>> 9.1, Xbase 2.00.972 and Windows 10 1607.
>>
>> Regards... Jonathan
Hi Paul,

In reviewing your example I found that tdcDEGet:LbDown(aPos) line 1451...

::xbpSle:LbDown(aPos)   allow selection of text with mouse

is causing the issue.  By commenting out this one line it stops the 
"undesirable" behavior but still allows one to select text once the get 
object gains input focus.  I have not done extensive testing but my 
initial tests seem to indicate that this resolves the issue.  I noticed 
that originally the same highlight issue occurred with tdcDEDate but 
commenting out line 1451 in tdcdeget resolved the issue as tdcdedate is 
derived from tdcdeget.

Here is a context view of the line in question...

IF ::oParentDlg:cMode != 'view'
    IF  (::oParentDlg:oActvGet == self)  if click on active get

       ******* this allows selection of text with mouse
       ::xbpSle:LbDown(aPos)

    ELSE   if click on different Get
       IF ::editable        is this Get in edit mode?

          IF ::oParentDlg:oActvGet != nil .AND. ;
               ::oParentDlg:oActvGet:bValid != nil .AND. ::lValidOnClick

             IF eval(::oParentDlg:oActvGet:bValid,::oParentDlg:oActvGet,0)

                IF ::receiveFocus(0)
                   lRetval := .T.
                   ::lFromMse := .T.
* LINE 1451       ::xbpSle:LbDown(aPos)   allow selection of text with 
mouse
                ENDIF

             ELSE   codeblock fails, put focus back where it was
                IF ! ::oParentDlg:oActvGet:lListvisible
                   setAppFocus(::oParentDlg:oActvGet)
                ENDIF
             ENDIF

          ELSE   no Validation needed


Hope this helps... Jonathan

jonathan.leeming@the-family-centre.com
Edmonton, Alberta, Canada
Paul ChongRe: tdDEget
on Fri, 27 Jul 2018 05:38:15 +0800
Hi Jonathan,

You are right. Commenting out line 1451 eliminate the highlight issue with
bValid. However, it doesn't work on tdcDEDate because it has a bWhen which
trigger by ::receiveFocus() at line 1462. I did a test to comment out line
1465 too, the same code as line 1451, and highlight issue with bWhen is
also eliminated.

So far so good. Except i just found out another problem. if edit focus is
on Phone Get (bValid with popups called) & i click on DOB Get (bWhen with
popups called), focus will not switch to DOB Get regardless if i choose
Yes/No from tdYesNo prompt as in TD91Demo.

But i think i may not use this combination in my code in future so i have
decided to stop debugging further.

Thank you for being helpful.

Paul

On Wed, 25 Jul 2018 08:28:49 -0600, Jonathan Leeming wrote:

> On 7/24/2018 10:55 PM, Paul Chong wrote:
>> Hi Jonathan,
>> 
>> I think the problem is at tdcDEget.prg. Refer to line 1462 - 1466. When the
>> new get receive focus by LbDown & the oActGet was assigned nil, xpbSle will
>> be treated as 'allow selection of text with mouse', line 1465.
>> 
>> Maybe this is the cause & that is why using keyboard is fine.
>> 
>> Any work around?
>> 
>> TIA
>> 
>> Paul
>> 
>> On Tue, 24 Jul 2018 07:50:16 -0600, Jonathan Leeming wrote:
>> 
>>> On 7/23/2018 11:32 PM, Paul Chong wrote:
>>>> Hi Jonathan,
>>>>
>>>> Your suggestion works. I have tested with the keyboard event and everything
>>>> is ok. Thanks. Surely its the modal focus problem.
>>>>
>>>> However, mouse click react a bit weird. If i click on another get, the new
>>>> get will receive focus but at the same time it is in highlight mode. As if
>>>> the mouse LBClick is being activated.
>>>>
>>>> For example, refer to screen shot, while focus is on IC NO, if i click on
>>>> Other between the '6' & '8' digit, Other get focus but when i move mouse
>>>> pointer to the right, it highlight part of the buffer.
>>>>
>>>> To release that highlight mode just click on the buffer again. Any idea how
>>>> to overcome this?
>>>>
>>>> TIA
>>>>
>>>> Paul
>>>>
>>>> On Mon, 23 Jul 2018 07:28:46 -0600, Jonathan Leeming wrote:
>>>>>
>>>>> As you noticed this happens with pretty much all popups called from
>>>>> within the validation routine.  I believe it is a result of a modal
>>>>> window conflicting with the SetInputFocus codeblock.
>>>>>
>>>>> The solution would be to add o:oParentDlg:oActvGet := NIL to the
>>>>> validation routine after the popup just before the return.
>>>>>
>>>>> Your bValid would then be:
>>>>>
>>>>> bValid := {|o,n| tdQMsg("How to exit block"), o:oParentDlg:oActvGet :=
>>>>> NIL, .T.}
>>>>>
>>>>> This should set the focus to the next get object as you expect.
>>>>>
>>>>> Regards... Jonathan
>>> Hi Paul,
>>>
>>> I tried to replicate the highlight issue but it does not occur within my
>>> application unless I right click...and hold... and move the mouse.  I
>>> did notice on one of my entry fields where I have the cPicture set to
>>> "@K" that the entire field get highlighted when I click anywhere in the
>>> field with a second click un-highlighting the field.  I don't know if
>>> other cPicture values give different behaviors.
>>>
>>> Is it possible to create a simple code snippet that replicates your issue?
>>>
>>> What version of Topdown, Xbase & Windows are you using.  I'm using TD
>>> 9.1, Xbase 2.00.972 and Windows 10 1607.
>>>
>>> Regards... Jonathan
> Hi Paul,
> 
> In reviewing your example I found that tdcDEGet:LbDown(aPos) line 1451...
> 
>::xbpSle:LbDown(aPos)   allow selection of text with mouse
> 
> is causing the issue.  By commenting out this one line it stops the 
> "undesirable" behavior but still allows one to select text once the get 
> object gains input focus.  I have not done extensive testing but my 
> initial tests seem to indicate that this resolves the issue.  I noticed 
> that originally the same highlight issue occurred with tdcDEDate but 
> commenting out line 1451 in tdcdeget resolved the issue as tdcdedate is 
> derived from tdcdeget.
> 
> Here is a context view of the line in question...
> 
> IF ::oParentDlg:cMode != 'view'
>     IF  (::oParentDlg:oActvGet == self)  if click on active get
> 
>        ******* this allows selection of text with mouse
>        ::xbpSle:LbDown(aPos)
> 
>     ELSE   if click on different Get
>        IF ::editable        is this Get in edit mode?
> 
>           IF ::oParentDlg:oActvGet != nil .AND. ;
>                ::oParentDlg:oActvGet:bValid != nil .AND. ::lValidOnClick
> 
>              IF eval(::oParentDlg:oActvGet:bValid,::oParentDlg:oActvGet,0)
> 
>                 IF ::receiveFocus(0)
>                    lRetval := .T.
>                    ::lFromMse := .T.
> * LINE 1451       ::xbpSle:LbDown(aPos)   allow selection of text with 
> mouse
>                 ENDIF
> 
>              ELSE   codeblock fails, put focus back where it was
>                 IF ! ::oParentDlg:oActvGet:lListvisible
>                    setAppFocus(::oParentDlg:oActvGet)
>                 ENDIF
>              ENDIF
> 
>           ELSE   no Validation needed
> 
> 
> Hope this helps... Jonathan
Paul ChongRe: tdDEget
on Wed, 25 Jul 2018 12:58:50 +0800
Oops. Forgot to post the code sample....

*****************************************************************************
*                      METHOD tdcDEget:LbDown()

 If user clicks on a Get this will enforce eval of a bWhen codeblock.
*****************************************************************************
METHOD tdcDEget:LbDown(aPos)
LOCAL oTip
LOCAL lRetval := .F.   only return T if this Get accepts focus
                       (for ALT_DOWN in keyhandler)

IF ::oParentDlg:nTipVer == 1 .AND. ::lHasMse
  oTip := tdSetToolTip()
  IF oTip != nil
     oTip:killtip()
  ENDIF
ENDIF

IF ::oParentDlg:cMode != 'view'
   IF  (::oParentDlg:oActvGet == self)  if click on active get

      ******* this allows selection of text with mouse
      ::xbpSle:LbDown(aPos)

   ELSE   if click on different Get
      IF ::editable        is this Get in edit mode?

         IF ::oParentDlg:oActvGet != nil .AND. ;
              ::oParentDlg:oActvGet:bValid != nil .AND. ::lValidOnClick

            IF eval(::oParentDlg:oActvGet:bValid,::oParentDlg:oActvGet,0)

               IF ::receiveFocus(0)
                  lRetval := .T.
                  ::lFromMse := .T.
                  ::xbpSle:LbDown(aPos)   allow selection of text with mouse
               ENDIF

            ELSE   codeblock fails, put focus back where it was
               IF ! ::oParentDlg:oActvGet:lListvisible
                  setAppFocus(::oParentDlg:oActvGet)
               ENDIF
            ENDIF

         ELSE   no Validation needed

L1462       IF ::receiveFocus(0)
L1463          lRetval := .T.
L1464          ::lFromMse := .T.
L1465          ::xbpSle:LbDown(aPos)   allow selection of text with mouse
L1466       ENDIF

         ENDIF

      ELSE
         IF valtype(::oParentDlg:oActvGet) == "O"
            setAppFocus(::oParentDlg:oActvGet)
         ENDIF
      ENDIF   editable
   ENDIF

ELSE   in 'view' mode

   ******* activate helpmsg if there is one
   IF ::aHelpmsg != nil .AND. ::oParentDlg:lViewModeHelp
      ::aHelpmsg[1]:setCaption(::aHelpmsg[2])
   ENDIF

   setAppFocus(self)
ENDIF

RETURN lRetval
*                     End of METHOD tdcDEget:LbDown()
*****************************************************************************
Paul ChongRe: tdDEget
on Tue, 24 Jul 2018 21:14:34 +0800
Forgot about the screenshot


ScrCap.jpg