Is this a bug?

Is this a bug?

Postby Patrick Mast » Tue Jul 08, 2008 4:34 am

Hello,

Please try following with code below:
1. Start the app
2. In colomn 1, you see rows with 111,222 and 333
3. In the browse, click with the mouse on row 2
4. Than, click with the mouse on row 3 in the browse
5. Now notice that column 1 of row 2 changed to 111

This is because I have the oGet:SetFocus() in the bLine of the browse.

Let me explain what I want to do:
If the user selects a row with his mouse, I want the GET to display the value of Column1 in the selected row AND set focus on the GET. This is important, because it is the SETFOCUS() that makes the value change in the browse.

Is this a bug or do I need to do it in a different way?

Thanks!!

Patrick

Code: Select all  Expand view  RUN
PROCEDURE Main()

   LOCAL oDlg, oBrw, n:=1, oGet
   LOCAL aData:={111,222,333}

   DEFINE DIALOG oDlg FROM 0,0 TO 25, 80

   @ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg
   
   oBrw:bLine    :={ || {Str(aData[n]),oGet:SetFocus()}}
   oBrw:bGoTop   :={ || n:=1 }
   oBrw:bGoBottom:={ || n:=Len(aData) }
   oBrw:bSkip    :={ | nSkip, nOld | nOld := n, n += nSkip,;
                     n := Max( 1, Min( n, Len(aData) ) ),;
                     n - nOld }
   oBrw:bLogicLen:={ || Len(aData) }
   oBrw:cAlias   :="Array"

   @ 10,2 GET oGet VAR aData[n] OF oDlg SIZE 90, 10
   
   ACTIVATE DIALOG oDlg

RETURN
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby nageswaragunupudi » Tue Jul 08, 2008 7:14 am

>
Is this a bug or do I need to do it in a different way?
>

No bug in wbrowse.prg. We need to do it this way:
Code: Select all  Expand view  RUN
#include 'fivewin.ch'

PROCEDURE Main()

   LOCAL oDlg, oBrw, n:=1, oGet
   LOCAL aData:={111,222,333}

   DEFINE DIALOG oDlg FROM 0,0 TO 25, 80

   @ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg

//   oBrw:bLine    :={ || {Str(aData[n]),oGet:SetFocus()}}
   oBrw:bLine    :=  { ||  {Str(aData[n]),' '} }  // instead of the original line
   oBrw:bGoTop   :={ || n:=1 }
   oBrw:bGoBottom:={ || n:=Len(aData) }
   oBrw:bSkip    :={ | nSkip, nOld | nOld := n, n += nSkip,;
                     n := Max( 1, Min( n, Len(aData) ) ),;
                     n - nOld }
   oBrw:bLogicLen:={ || Len(aData) }
   oBrw:cAlias   :="Array"

   oBrw:bChange   := { || oGet:SetFocus() } // inserted

   @ 10,2 GET oGet VAR aData[ n ] OF oDlg SIZE 90, 10   

   ACTIVATE DIALOG oDlg

RETURN

Last edited by nageswaragunupudi on Tue Jul 08, 2008 8:06 am, edited 2 times in total.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Tue Jul 08, 2008 7:32 am

Because of my personal preference to xBrowse, I am tempted to post a working example with xBrowse also:
Code: Select all  Expand view  RUN
#include 'fivewin.ch'
#include 'xbrowse.ch'

PROCEDURE Main()

   LOCAL oDlg, oBrw, oGet
   LOCAL aData:= { 111, 222, 333}

   DEFINE DIALOG oDlg FROM 0,0 TO 25, 80

   @ 0,0 XBROWSE oBrw ;
      HEADERS 'Select' ;
      SIZE 310,100 OF oDlg ;
      ON CHANGE oGet:SetFocus()  ;
      ARRAY aData AUTOCOLS

   oBrw:CreateFromCode()

   @ 10,2 GET oGet VAR aData[ oBrw:nArrayAt ] OF oDlg SIZE 90, 10

   ACTIVATE DIALOG oDlg CENTERED

RETURN
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby mmercado » Tue Jul 08, 2008 3:15 pm

nageswaragunupudi wrote: oBrw:bChange := { || oGet:SetFocus() } // inserted
Hi both:

I think for Patrick's purposes it's better to use bLClicked instead of bChange because if user clicks the same row, the browse gain focus.

Regards.

Manuel Mercado
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Patrick Mast » Tue Jul 08, 2008 4:02 pm

nageswaragunupudi wrote:No bug in wbrowse.prg. We need to do it this way:
Code: Select all  Expand view  RUN
#include 'fivewin.ch'
...
   oBrw:bChange   := { || oGet:SetFocus() } // inserted
Great! Thanks!
Now, this works OK if I click on one of the rows in the browse, but if I click on the browse itself, so NOT on a row with data in it, the GET does not get focused.

So to sumarize:

With oBrw:bChange:={ || oGet:SetFocus() }
-> Click on row with data = OK
-> Click on oBrw = NOT OK
-> Click on vertical scrollbar while row 2 is active -> OK
-> Move throug browse with keyboard arrows -> NOT OK

With oBrw:bLClicked:={ || oGet:SetFocus() }
-> Click on row with data = OK
-> Click on oBrw = NOT OK
-> Click on vertical scrollbar while row 2 is active -> NOT OK
-> Move throug browse with keyboard arrows -> NOT OK

With oBrw:bGotFocus:={ || oGet:SetFocus() }
-> Click on row with data = NOT OK
-> Click on oBrw = NOT OK
-> Click on vertical scrollbar while row 2 is active -> NOT OK
-> Move throug browse with keyboard arrows -> NOT OK

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby nageswaragunupudi » Tue Jul 08, 2008 4:13 pm

>
With oBrw:bChange:={ || oGet:SetFocus() }
-> Click on oBrw = NOT OK

>
How we program depends on what we want to happen for Cick on Brw in area not containing data
>


>
-> Move throug browse with keyboard arrows -> NOT OK
>

Moving through browse with key board arrows also changes the Get's value to the new row. I thought thats what is intended. If what is wanted is different, then we need to program for that
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Patrick Mast » Tue Jul 08, 2008 4:40 pm

nageswaragunupudi wrote:Moving through browse with key board arrows also changes the Get's value to the new row. I thought thats what is intended. If what is wanted is different, then we need to program for that
Yes, everything needs to work ;-)

Thanks for helping!

Antonio, do you have an idea?

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Patrick Mast » Thu Jul 10, 2008 5:58 am

I have this bug in my application. Antonio, do you have a fix for this? Maybe anyone else with a fix for this?

Thanks!!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Enrico Maria Giordano » Thu Jul 10, 2008 9:02 am

Patrick, please explain what do you exactly want to do.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Patrick Mast » Thu Jul 10, 2008 3:10 pm

Enrico Maria Giordano wrote:Patrick, please explain what do you exactly want to do.
Enrico,
Simple; I want the GET to ALWAYS have focus and it should have the value of the active row in the browse.

The problem started when I noticed that, when you use the scrollbar to navigate, the value IN the browse changed.

So, again, I want the GET to have ALWAYS focus and the value in the get should be the active row.

Thanks for helping!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby nageswaragunupudi » Thu Jul 10, 2008 4:06 pm

If understand correctly, the intention is that the Browse should never get focus, whatever the user does, including Tabbing, clicking on non-data area of the browse or using the scroll bar.

The following code seems to work.
Code: Select all  Expand view  RUN
PROCEDURE Main()

   LOCAL oDlg, oBrw, n := 1, oGet
   LOCAL aData:={111,222,333}

   DEFINE DIALOG oDlg FROM 0,0 TO 25, 80

   @ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg

   oBrw:bLine     :=  { ||  {Str(aData[n]),' '} }
   oBrw:bGoTop    :={ || n:=1 }
   oBrw:bGoBottom :={ || n:=Len(aData) }
   oBrw:bSkip     :={ | nSkip, nOld | nOld := n, n += nSkip,;
                     n := Max( 1, Min( n, Len(aData) ) ),;
                     n - nOld }
   oBrw:bLogicLen :={ || Len(aData) }
   oBrw:cAlias    :="Array"

   oBrw:bChange   := { || oGet:SetFocus() }
   oBrw:bGotFocus := { || oGet:SetFocus() }

   // following two lines to visibly make sure
   // where the focus is
   oBrw:nClrBackFocus := CLR_GREEN  // browse shd never show green
   SetGetColorFocus()  // Get should always retain the color


   @ 10,2 GET oGet VAR aData[n] OF oDlg SIZE 90, 10

   ACTIVATE DIALOG oDlg CENTERED

RETURN

We may add oBrw:nStyle -= WS_TABSTOP. but this seems work even without that.

Does this example serve the intended purpose please?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Patrick Mast » Thu Jul 10, 2008 4:28 pm

nageswaragunupudi wrote:If understand correctly, the intention is that the Browse should never get focus, whatever the user does, including Tabbing, clicking on non-data area of the browse or using the scroll bar.

The following code seems to work.
Code: Select all  Expand view  RUN
PROCEDURE Main()
...
   oBrw:bChange   := { || oGet:SetFocus() }
   oBrw:bGotFocus := { || oGet:SetFocus() }
...
RETURN

We may add oBrw:nStyle -= WS_TABSTOP. but this seems work even without that.

Does this example serve the intended purpose please?

Thank you but this behaves not correctly.

Please try this:
1. Start the app
2. Click on row 2
-> Get still has 111 as vallue, so this is wrong
3. Than click on row 3
-> The get still has vallue 111, but worse, the browse column 1 of row 2 ALSO gets the vallue of 111
4. Than click on row 2 again
-> The get still has 111, and the vallue of row 3 of the browse als has 111

Its the changing of the vallues IN the browse that got me thinking this is abug somewhere.

So, 2 things needs to be fixed here.
1. The vallue of the GET should get updated
2. The vallues in the browse schould NOT change

Thanks for helping! ;-)

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Thu Jul 10, 2008 4:58 pm

IMO the GET should not directly modify aData[ n ], because when it loses focus (though later on, it recovers it) then aData[ n ] is asigned with the GET contents (111).

The GET should work on a local variable, and the bChange of the browse should update that local variable.

Unless I am missing something :-)
Last edited by Antonio Linares on Thu Jul 10, 2008 5:02 pm, edited 1 time in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Jul 10, 2008 5:01 pm

Code: Select all  Expand view  RUN
#include "FiveWin.ch"

PROCEDURE Main()

   LOCAL oDlg, oBrw, n := 1, oGet
   LOCAL aData:={111,222,333}
   LOCAL cValue := aData[ 1 ]

   DEFINE DIALOG oDlg FROM 0,0 TO 25, 80

   @ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg

   oBrw:bLine     :=  { ||  {Str(aData[n]),' '} }
   oBrw:bGoTop    :={ || n:=1 }
   oBrw:bGoBottom :={ || n:=Len(aData) }
   oBrw:bSkip     :={ | nSkip, nOld | nOld := n, n += nSkip,;
                     n := Max( 1, Min( n, Len(aData) ) ),;
                     n - nOld }
   oBrw:bLogicLen :={ || Len(aData) }
   oBrw:cAlias    :="Array"

   oBrw:bChange   := { || oGet:VarPut( aData[ n ] ), oGet:Refresh(), oGet:SetFocus() }
   oBrw:bGotFocus := { || oGet:SetFocus() }

   // following two lines to visibly make sure
   // where the focus is
   oBrw:nClrBackFocus := CLR_GREEN  // browse shd never show green
   SetGetColorFocus()  // Get should always retain the color


   @ 10,2 GET oGet VAR cValue OF oDlg SIZE 90, 10

   ACTIVATE DIALOG oDlg CENTERED

RETURN
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Thu Jul 10, 2008 5:08 pm

Antonio,

Works perfect! ;-)
Thank you very much.

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 55 guests